-
-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7fb3165
commit b3d1c0c
Showing
3 changed files
with
145 additions
and
0 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
14 changes: 14 additions & 0 deletions
14
docs/src/app/(private)/experiments/toolbar/triggers.module.css
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,14 @@ | ||
.Root { | ||
background-color: var(--color-gray-100); | ||
padding: 0 0.75rem; | ||
} | ||
|
||
.Toggle { | ||
margin-block: 0.5rem; | ||
} | ||
|
||
.Separator[data-orientation='vertical'] { | ||
width: 1px; | ||
align-self: stretch; | ||
background-color: var(--color-gray-200); | ||
} |
102 changes: 102 additions & 0 deletions
102
docs/src/app/(private)/experiments/toolbar/triggers.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,102 @@ | ||
'use client'; | ||
import * as React from 'react'; | ||
import { Toolbar } from '@base-ui-components/react/toolbar'; | ||
import { Toggle } from '@base-ui-components/react/toggle'; | ||
import { Switch } from '@base-ui-components/react/switch'; | ||
import { Dialog } from '@base-ui-components/react/dialog'; | ||
import toolbarClasses from './toolbar.module.css'; | ||
import triggerToolbarClasses from './triggers.module.css'; | ||
import switchClasses from '../../../(public)/(content)/react/components/switch/demos/hero/css-modules/index.module.css'; | ||
import dialogClasses from '../../../(public)/(content)/react/components/alert-dialog/demos/hero/css-modules/index.module.css'; | ||
import popoverClasses from '../../../(public)/(content)/react/components/popover/demos/hero/css-modules/index.module.css'; | ||
import { MessageCircleIcon } from './_icons'; | ||
|
||
const styles = { | ||
demo: triggerToolbarClasses, | ||
toolbar: toolbarClasses, | ||
switch: switchClasses, | ||
dialog: dialogClasses, | ||
}; | ||
|
||
const TEXT = `Shows toolbar buttons as various triggers: | ||
- Menu.Trigger | ||
- Dialog.Trigger | ||
- Popover.Trigger | ||
`; | ||
|
||
const DISABLED = false; | ||
|
||
function classNames(...c: Array<string | undefined | null | false>) { | ||
return c.filter(Boolean).join(' '); | ||
} | ||
|
||
export default function App() { | ||
return ( | ||
<React.Fragment> | ||
<a | ||
className={styles.toolbar.a} | ||
href="https://www.w3.org/WAI/ARIA/apg/patterns/toolbar/" | ||
target="_blank" | ||
rel="noreferrer" | ||
> | ||
<h3 className={styles.toolbar.h3}>Toolbar pattern</h3> | ||
</a> | ||
<div className={styles.toolbar.Wrapper}> | ||
<Toolbar.Root className={classNames(styles.toolbar.Root, styles.demo.Root)}> | ||
<Dialog.Root> | ||
<Toolbar.Button | ||
disabled={DISABLED} | ||
className={classNames(styles.toolbar.Toggle, styles.demo.Toggle)} | ||
render={ | ||
<Dialog.Trigger> | ||
<MessageCircleIcon className={styles.toolbar.Icon} /> | ||
</Dialog.Trigger> | ||
} | ||
/> | ||
|
||
<Dialog.Portal keepMounted> | ||
<Dialog.Backdrop className={styles.dialog.Backdrop} /> | ||
<Dialog.Popup className={styles.dialog.Popup}> | ||
<Dialog.Title className={styles.dialog.Title}> | ||
Write a comment | ||
</Dialog.Title> | ||
<textarea name="" id="" className={styles.toolbar.Textarea} /> | ||
<div className={styles.dialog.Actions}> | ||
<Dialog.Close data-color="red" className={styles.dialog.Button}> | ||
Close | ||
</Dialog.Close> | ||
<Dialog.Close className={styles.dialog.Button}> | ||
Submit | ||
</Dialog.Close> | ||
</div> | ||
</Dialog.Popup> | ||
</Dialog.Portal> | ||
</Dialog.Root> | ||
|
||
<Toolbar.Separator className={styles.demo.Separator} /> | ||
|
||
<Toolbar.Button | ||
disabled={DISABLED} | ||
className={classNames(styles.toolbar.Toggle, styles.demo.Toggle)} | ||
render={ | ||
<Switch.Root defaultChecked className={styles.switch.Switch}> | ||
<Switch.Thumb | ||
className={styles.switch.Thumb} | ||
style={{ marginRight: 'auto' }} | ||
/> | ||
</Switch.Root> | ||
} | ||
/> | ||
</Toolbar.Root> | ||
|
||
<textarea | ||
className={styles.toolbar.Textarea} | ||
name="" | ||
id="" | ||
rows={8} | ||
defaultValue={TEXT} | ||
/> | ||
</div> | ||
</React.Fragment> | ||
); | ||
} |