-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28693 from storybookjs/sidebar-bottom-filters
UI: Replace `experimental_SIDEBAR_BOTTOM` API with a status filter UI
- Loading branch information
Showing
12 changed files
with
309 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
code/core/src/manager/components/sidebar/FilterToggle.stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { fn } from '@storybook/test'; | ||
import { FilterToggle } from './FilterToggle'; | ||
|
||
export default { | ||
component: FilterToggle, | ||
args: { | ||
active: false, | ||
onClick: fn(), | ||
}, | ||
}; | ||
|
||
export const Errors = { | ||
args: { | ||
count: 2, | ||
label: 'Error', | ||
status: 'critical', | ||
}, | ||
}; | ||
|
||
export const ErrorsActive = { | ||
args: { | ||
...Errors.args, | ||
active: true, | ||
}, | ||
}; | ||
|
||
export const Warning = { | ||
args: { | ||
count: 12, | ||
label: 'Warning', | ||
status: 'warning', | ||
}, | ||
}; | ||
|
||
export const WarningActive = { | ||
args: { | ||
...Warning.args, | ||
active: true, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { Badge as BaseBadge, IconButton } from '@storybook/components'; | ||
import { css, styled } from '@storybook/theming'; | ||
import React, { type ComponentProps } from 'react'; | ||
|
||
const Badge = styled(BaseBadge)(({ theme }) => ({ | ||
padding: '4px 8px', | ||
fontSize: theme.typography.size.s1, | ||
})); | ||
|
||
const Button = styled(IconButton)( | ||
({ theme }) => ({ | ||
fontSize: theme.typography.size.s2, | ||
'&:hover [data-badge][data-status=warning], [data-badge=true][data-status=warning]': { | ||
background: '#E3F3FF', | ||
borderColor: 'rgba(2, 113, 182, 0.1)', | ||
color: '#0271B6', | ||
}, | ||
'&:hover [data-badge][data-status=critical], [data-badge=true][data-status=critical]': { | ||
background: theme.background.negative, | ||
boxShadow: `inset 0 0 0 1px rgba(182, 2, 2, 0.1)`, | ||
color: theme.color.negativeText, | ||
}, | ||
}), | ||
({ active, theme }) => | ||
!active && | ||
css({ | ||
'&:hover': { | ||
color: theme.base === 'light' ? theme.color.defaultText : theme.color.light, | ||
}, | ||
}) | ||
); | ||
|
||
const Label = styled.span(({ theme }) => ({ | ||
color: theme.base === 'light' ? theme.color.defaultText : theme.color.light, | ||
})); | ||
|
||
interface FilterToggleProps { | ||
active: boolean; | ||
count: number; | ||
label: string; | ||
status: ComponentProps<typeof Badge>['status']; | ||
} | ||
|
||
export const FilterToggle = ({ | ||
active, | ||
count, | ||
label, | ||
status, | ||
...props | ||
}: FilterToggleProps & Omit<ComponentProps<typeof Button>, 'status'>) => { | ||
return ( | ||
<Button active={active} {...props}> | ||
<Badge status={status} data-badge={active} data-status={status}> | ||
{count} | ||
</Badge> | ||
<Label>{`${label}${count === 1 ? '' : 's'}`}</Label> | ||
</Button> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
code/core/src/manager/components/sidebar/SidebarBottom.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { fn } from '@storybook/test'; | ||
|
||
import { SidebarBottomBase } from './SidebarBottom'; | ||
|
||
export default { | ||
component: SidebarBottomBase, | ||
args: { | ||
api: { | ||
experimental_setFilter: fn(), | ||
emit: fn(), | ||
}, | ||
}, | ||
}; | ||
|
||
export const Errors = { | ||
args: { | ||
status: { | ||
one: { 'sidebar-bottom-filter': { status: 'error' } }, | ||
two: { 'sidebar-bottom-filter': { status: 'error' } }, | ||
}, | ||
}, | ||
}; | ||
|
||
export const Warnings = { | ||
args: { | ||
status: { | ||
one: { 'sidebar-bottom-filter': { status: 'warn' } }, | ||
two: { 'sidebar-bottom-filter': { status: 'warn' } }, | ||
}, | ||
}, | ||
}; | ||
|
||
export const Both = { | ||
args: { | ||
status: { | ||
one: { 'sidebar-bottom-filter': { status: 'warn' } }, | ||
two: { 'sidebar-bottom-filter': { status: 'warn' } }, | ||
three: { 'sidebar-bottom-filter': { status: 'error' } }, | ||
four: { 'sidebar-bottom-filter': { status: 'error' } }, | ||
}, | ||
}, | ||
}; |
Oops, something went wrong.