-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(components): add `Toolbar` and `Calendar` presets * chore: format * fix: biome * feat: add spacing variants * fix: version
- Loading branch information
Showing
22 changed files
with
516 additions
and
74 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@launchpad-ui/components": patch | ||
--- | ||
|
||
Add `Toolbar` and `Calendar` presets |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
|
||
import { render, screen } from '../../../test/utils'; | ||
import { Button, Group, IconButton, Separator, Toolbar } from '../src'; | ||
|
||
describe('Toolbar', () => { | ||
it('renders', () => { | ||
render( | ||
<Toolbar> | ||
<Group> | ||
<Button size="small">Cut</Button> | ||
<Button size="small">Copy</Button> | ||
<Button size="small">Paste</Button> | ||
</Group> | ||
<Separator orientation="vertical" /> | ||
<Group> | ||
<IconButton icon="gear" aria-label="settings" size="small" /> | ||
<IconButton icon="help" aria-label="help" size="small" /> | ||
</Group> | ||
</Toolbar>, | ||
); | ||
expect(screen.getByRole('toolbar')).toBeVisible(); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import type { VariantProps } from 'class-variance-authority'; | ||
import type { ForwardedRef } from 'react'; | ||
import type { ToolbarProps as AriaToolbarProps } from 'react-aria-components'; | ||
|
||
import { cva } from 'class-variance-authority'; | ||
import { forwardRef } from 'react'; | ||
import { Toolbar as AriaToolbar, composeRenderProps } from 'react-aria-components'; | ||
|
||
import styles from './styles/Toolbar.module.css'; | ||
|
||
const toolbar = cva(styles.base, { | ||
variants: { | ||
spacing: { | ||
basic: styles.basic, | ||
compact: styles.compact, | ||
large: styles.large, | ||
}, | ||
}, | ||
defaultVariants: { | ||
spacing: 'basic', | ||
}, | ||
}); | ||
|
||
interface ToolbarProps extends AriaToolbarProps, VariantProps<typeof toolbar> {} | ||
|
||
const _Toolbar = ( | ||
{ spacing = 'basic', ...props }: ToolbarProps, | ||
ref: ForwardedRef<HTMLDivElement>, | ||
) => { | ||
return ( | ||
<AriaToolbar | ||
{...props} | ||
ref={ref} | ||
className={composeRenderProps(props.className, (className, renderProps) => | ||
toolbar({ ...renderProps, spacing, className }), | ||
)} | ||
/> | ||
); | ||
}; | ||
|
||
/** | ||
* A toolbar is a container for a set of interactive controls, such as buttons, dropdown menus, or checkboxes, with arrow key navigation. | ||
* | ||
* https://react-spectrum.adobe.com/react-aria/Toolbar.html | ||
*/ | ||
const Toolbar = forwardRef(_Toolbar); | ||
|
||
export { Toolbar }; | ||
export type { ToolbarProps }; |
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
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
Oops, something went wrong.