overleaf/services/web/frontend/stories/split-menu.stories.tsx
M Fahru b62cb86bf8 Create new SplitMenu component and implement it for the pdf compile button (detached & non-detached) (#11772)
* Create a new shared `SplitMenu` component.

* Refactor the pdf compile button & detached compile button:
    - Rename `detach-compile-button` to `detach-compile-button-wrapper`
    - Rename `pdf-compile-button-inner` to `detach-compile-button`
    - Move some of the logic from `detach-compile-button-wrapper` to `detach-compile-button`
    - Create a new `compile-button.less` to centralize all of the compile button (detached/non-detached) custom styles rule.
    - Extract the animated striped CSS definition to the dedicated CSS file, change the class from `btn-recompile-group-has-changes` to `btn-striped-animated`
    - Refactor other className(s) appropriately according to the new component name
    - Delete the unused `changes-to-autocompile` css rule since it has not been used anywhere

* Implement the new pdf compile button with the new `SplitMenu` component.

GitOrigin-RevId: d1d055bffd311923fc47b4681605ce8ba8e26f25
2023-02-22 09:04:42 +00:00

225 lines
4.8 KiB
TypeScript

import SplitMenu from '../js/shared/components/split-menu'
export const PrimaryWithoutTooltip = () => {
return (
<SplitMenu
bsStyle="primary"
button={{
text: 'Button',
}}
dropdown={{
id: 'pdf-recompile-dropdown',
}}
>
<SplitMenu.Item>tes</SplitMenu.Item>
</SplitMenu>
)
}
export const PrimaryWithTooltip = () => {
return (
<SplitMenu
bsStyle="primary"
button={{
text: 'Button',
tooltip: {
description: 'tooltip description',
id: 'tooltip-storybook',
overlayProps: {
placement: 'bottom',
},
},
}}
dropdown={{
id: 'pdf-recompile-dropdown',
}}
>
<SplitMenu.Item>tes</SplitMenu.Item>
</SplitMenu>
)
}
export const Disabled = () => {
return (
<div>
<h2>Primary</h2>
<SplitMenu
bsStyle="primary"
disabled
button={{
text: 'Button',
}}
dropdown={{
id: 'pdf-recompile-dropdown',
}}
dropdownToggle={{}}
>
<SplitMenu.Item>tes</SplitMenu.Item>
</SplitMenu>
<hr />
<h2>Secondary</h2>
<SplitMenu
bsStyle="secondary"
disabled
button={{
text: 'Button',
}}
dropdown={{
id: 'pdf-recompile-dropdown',
}}
dropdownToggle={{}}
>
<SplitMenu.Item>tes</SplitMenu.Item>
</SplitMenu>
<hr />
<h2>Danger</h2>
<SplitMenu
bsStyle="danger"
disabled
button={{
text: 'Button',
}}
dropdown={{
id: 'pdf-recompile-dropdown',
}}
dropdownToggle={{}}
>
<SplitMenu.Item>tes</SplitMenu.Item>
</SplitMenu>
</div>
)
}
export const DifferentSizeAndStyle = () => {
return (
<div>
<h2>Default (medium)</h2>
<div style={{ display: 'flex', gap: '10px' }}>
<SplitMenu
bsStyle="primary"
bsSize="md"
button={{
text: 'Button',
}}
dropdown={{
id: 'pdf-recompile-dropdown',
}}
>
<SplitMenu.Item>tes</SplitMenu.Item>
</SplitMenu>
<SplitMenu
bsStyle="secondary"
bsSize="md"
button={{
text: 'Button',
}}
dropdown={{
id: 'pdf-recompile-dropdown',
}}
>
<SplitMenu.Item>tes</SplitMenu.Item>
</SplitMenu>
<SplitMenu
bsStyle="danger"
bsSize="md"
button={{
text: 'Button',
}}
dropdown={{
id: 'pdf-recompile-dropdown',
}}
>
<SplitMenu.Item>tes</SplitMenu.Item>
</SplitMenu>
</div>
<hr />
<h2>Small</h2>
<div style={{ display: 'flex', gap: '10px' }}>
<SplitMenu
bsStyle="primary"
bsSize="sm"
button={{
text: 'Button',
}}
dropdown={{
id: 'pdf-recompile-dropdown',
}}
>
<SplitMenu.Item>tes</SplitMenu.Item>
</SplitMenu>
<SplitMenu
bsStyle="secondary"
bsSize="sm"
button={{
text: 'Button',
}}
dropdown={{
id: 'pdf-recompile-dropdown',
}}
>
<SplitMenu.Item>tes</SplitMenu.Item>
</SplitMenu>
<SplitMenu
bsStyle="danger"
bsSize="sm"
button={{
text: 'Button',
}}
dropdown={{
id: 'pdf-recompile-dropdown',
}}
>
<SplitMenu.Item>tes</SplitMenu.Item>
</SplitMenu>
</div>
<hr />
<h2>Extra Small</h2>
<div style={{ display: 'flex', gap: '10px' }}>
<SplitMenu
bsStyle="primary"
bsSize="xs"
button={{
text: 'Button',
}}
dropdown={{
id: 'pdf-recompile-dropdown',
}}
>
<SplitMenu.Item>tes</SplitMenu.Item>
</SplitMenu>
<SplitMenu
bsStyle="secondary"
bsSize="xs"
button={{
text: 'Button',
}}
dropdown={{
id: 'pdf-recompile-dropdown',
}}
>
<SplitMenu.Item>tes</SplitMenu.Item>
</SplitMenu>
<SplitMenu
bsStyle="danger"
bsSize="xs"
button={{
text: 'Button',
}}
dropdown={{
id: 'pdf-recompile-dropdown',
}}
>
<SplitMenu.Item>tes</SplitMenu.Item>
</SplitMenu>
</div>
</div>
)
}
export default {
title: 'Shared / Components / Split Menu',
component: SplitMenu,
args: {
source: 'storybook',
},
}