Merge pull request #3223 from overleaf/ta-dropdown-stories

Dropdowns: A File Tree Storybook
GitOrigin-RevId: 0a5e911032accac1f5632de26b7ec69524ea04f9
This commit is contained in:
Alasdair Smith 2020-09-25 09:40:38 +01:00 committed by Copybot
parent f5449dc4b0
commit 49d5bb0591
2 changed files with 110 additions and 0 deletions

View file

@ -0,0 +1,97 @@
import React from 'react'
import { Dropdown, DropdownButton, MenuItem } from 'react-bootstrap'
import Icon from '../js/shared/components/icon'
const MenuItems = () => (
<>
<MenuItem eventKey="1">Action</MenuItem>
<MenuItem eventKey="2">Another action</MenuItem>
<MenuItem eventKey="3" active>
Active Item
</MenuItem>
<MenuItem divider />
<MenuItem eventKey="4">Separated link</MenuItem>
</>
)
const defaultArgs = {
bsStyle: 'default',
title: 'Dropdown',
pullRight: false,
noCaret: false,
className: '',
defaultOpen: true
}
export const Default = args => {
return (
<DropdownButton {...args}>
<MenuItems />
</DropdownButton>
)
}
Default.args = { ...defaultArgs }
export const Primary = args => {
return (
<DropdownButton {...args}>
<MenuItems />
</DropdownButton>
)
}
Primary.args = { ...defaultArgs, bsStyle: 'primary' }
export const RightAligned = args => {
return (
<div style={{ 'text-align': 'right' }}>
<DropdownButton {...args}>
<MenuItems />
</DropdownButton>
</div>
)
}
RightAligned.args = { ...defaultArgs, pullRight: true }
export const SingleIconTransparent = args => {
return (
<div style={{ 'text-align': 'right' }}>
<DropdownButton {...args}>
<MenuItems />
</DropdownButton>
</div>
)
}
SingleIconTransparent.args = {
...defaultArgs,
pullRight: true,
title: <Icon type="ellipsis-v" />,
noCaret: true,
className: 'dropdown-toggle-no-background'
}
export const Customized = args => {
return (
<Dropdown pullRight={args.pullRight} defaultOpen={args.defaultOpen}>
<Dropdown.Toggle
noCaret={args.noCaret}
className={args.className}
bsStyle={args.bsStyle}
>
{args.title}
</Dropdown.Toggle>
<Dropdown.Menu>
<MenuItems />
</Dropdown.Menu>
</Dropdown>
)
}
Customized.args = {
...defaultArgs,
component: Dropdown,
title: 'Toggle & Menu used separately'
}
export default {
title: 'Dropdown',
component: DropdownButton
}

View file

@ -20,6 +20,19 @@
position: relative;
}
.open button.dropdown-toggle.dropdown-toggle-no-background,
button.dropdown-toggle.dropdown-toggle-no-background {
background-color: transparent;
box-shadow: none;
border: 0;
&:hover,
&:active,
&:focus {
background-color: transparent;
box-shadow: none;
}
}
// Prevent the focus on the dropdown toggle when closing dropdowns
.dropdown-toggle:focus {
outline: 0;