-
-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Toolbar] Add Toolbar components #1349
Draft
mj12albert
wants to merge
15
commits into
mui:master
Choose a base branch
from
mj12albert:feat/toolbar
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
a77bb6d
Add Toolbar components
mj12albert 75f8b42
Make ToggleGroup work in Toolbar
mj12albert a4439fa
Add toolbar button
mj12albert fd31187
Enable toggling focuseableWhenDisabled on toolbar buttons
mj12albert e2bc95d
Update demo
mj12albert a492b65
Add toolbar link
mj12albert 0fdc446
Add cols prop
mj12albert abc4b42
Fix registering ToolbarLink as composite item
mj12albert 6ee1ccb
Allow Composite to override tabIndex in useButton
mj12albert 0e93632
Generate docs
mj12albert 209a996
Add ToolbarSeparator
mj12albert 2ee9e9a
Update experiments
mj12albert 5fe85d2
Add settings to experiments
mj12albert 4e49528
Fix disabled states
mj12albert 090aee3
Don't set native disabled attr if useButton is a composite item
mj12albert File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Make ToggleGroup work in Toolbar
- Loading branch information
commit 75f8b42e8bc89abaf3c62cb0e51d5805728722ab
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,93 @@ | ||
.Root { | ||
display: flex; | ||
gap: 0.5rem; | ||
border: 1px solid var(--color-gray-200); | ||
border-radius: 0.375rem; | ||
background-color: var(--color-gray-50); | ||
padding: 0.125rem; | ||
text-wrap: nowrap; | ||
} | ||
|
||
.Separator { | ||
width: 1px; | ||
margin-block: 2px; | ||
background-color: var(--color-gray-300); | ||
} | ||
|
||
.Link { | ||
font-size: 0.875rem; | ||
line-height: 1.25rem; | ||
color: var(--color-gray-900); | ||
text-decoration-color: var(--color-gray-400); | ||
text-decoration-thickness: 1px; | ||
text-decoration-line: none; | ||
text-underline-offset: 2px; | ||
|
||
@media (hover: hover) { | ||
&:hover { | ||
text-decoration-line: underline; | ||
} | ||
} | ||
|
||
&:focus-visible { | ||
border-radius: 0.125rem; | ||
outline: 2px solid var(--color-blue); | ||
text-decoration-line: none; | ||
} | ||
} | ||
|
||
/* ToggleGroup */ | ||
.ToggleGroup { | ||
display: flex; | ||
gap: 1px; | ||
border-radius: 0.375rem; | ||
padding: 0.125rem; | ||
} | ||
|
||
.Toggle { | ||
box-sizing: border-box; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
width: 2rem; | ||
height: 2rem; | ||
padding: 0; | ||
margin: 0; | ||
outline: 0; | ||
border: 0; | ||
border-radius: 0.25rem; | ||
background-color: transparent; | ||
color: var(--color-gray-600); | ||
user-select: none; | ||
|
||
&:focus-visible { | ||
background-color: transparent; | ||
outline: 2px solid var(--color-blue); | ||
outline-offset: -1px; | ||
} | ||
|
||
@media (hover: hover) { | ||
&:hover { | ||
background-color: var(--color-gray-100); | ||
} | ||
} | ||
|
||
&:active { | ||
background-color: var(--color-gray-200); | ||
} | ||
|
||
&[data-pressed] { | ||
background-color: var(--color-gray-100); | ||
color: var(--color-gray-900); | ||
} | ||
} | ||
|
||
.Icon { | ||
width: 1rem; | ||
height: 1rem; | ||
fill: none; | ||
stroke: currentColor; | ||
stroke-width: 2; | ||
stroke-linecap: round; | ||
stroke-linejoin: round; | ||
} |
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,136 @@ | ||
'use client'; | ||
import * as React from 'react'; | ||
import { Toolbar } from '@base-ui-components/react/toolbar'; | ||
import { Toggle } from '@base-ui-components/react/toggle'; | ||
import { ToggleGroup } from '@base-ui-components/react/toggle-group'; | ||
import s from './toolbar.module.css'; | ||
import '../../../demo-theme.css'; | ||
|
||
export default function App() { | ||
return ( | ||
<Toolbar.Root className={s.Root}> | ||
<ToggleGroup defaultValue={[]} className={s.ToggleGroup}> | ||
<Toggle aria-label="Bold" value="bold" className={s.Toggle}> | ||
<BoldIcon className={s.Icon} /> | ||
</Toggle> | ||
<Toggle aria-label="Italics" value="italics" className={s.Toggle}> | ||
<ItalicsIcon className={s.Icon} /> | ||
</Toggle> | ||
<Toggle aria-label="Underline" value="underline" className={s.Toggle}> | ||
<UnderlineIcon className={s.Icon} /> | ||
</Toggle> | ||
</ToggleGroup> | ||
|
||
<Toolbar.Separator className={s.Separator} /> | ||
|
||
<ToggleGroup defaultValue={['left']} className={s.ToggleGroup}> | ||
<Toggle aria-label="Align left" value="left" className={s.Toggle}> | ||
<AlignLeftIcon className={s.Icon} /> | ||
</Toggle> | ||
<Toggle aria-label="Align center" value="center" className={s.Toggle}> | ||
<AlignCenterIcon className={s.Icon} /> | ||
</Toggle> | ||
<Toggle aria-label="Align right" value="right" className={s.Toggle}> | ||
<AlignRightIcon className={s.Icon} /> | ||
</Toggle> | ||
</ToggleGroup> | ||
</Toolbar.Root> | ||
); | ||
} | ||
|
||
function AlignLeftIcon(props: React.ComponentProps<'svg'>) { | ||
return ( | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
width="24" | ||
height="24" | ||
viewBox="0 0 24 24" | ||
{...props} | ||
> | ||
<line x1="17" y1="10" x2="3" y2="10" /> | ||
<line x1="21" y1="6" x2="3" y2="6" /> | ||
<line x1="21" y1="14" x2="3" y2="14" /> | ||
<line x1="17" y1="18" x2="3" y2="18" /> | ||
</svg> | ||
); | ||
} | ||
|
||
function AlignCenterIcon(props: React.ComponentProps<'svg'>) { | ||
return ( | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
width="24" | ||
height="24" | ||
viewBox="0 0 24 24" | ||
{...props} | ||
> | ||
<line x1="18" y1="10" x2="6" y2="10" /> | ||
<line x1="21" y1="6" x2="3" y2="6" /> | ||
<line x1="21" y1="14" x2="3" y2="14" /> | ||
<line x1="18" y1="18" x2="6" y2="18" /> | ||
</svg> | ||
); | ||
} | ||
|
||
function AlignRightIcon(props: React.ComponentProps<'svg'>) { | ||
return ( | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
width="24" | ||
height="24" | ||
viewBox="0 0 24 24" | ||
{...props} | ||
> | ||
<line x1="21" y1="10" x2="7" y2="10" /> | ||
<line x1="21" y1="6" x2="3" y2="6" /> | ||
<line x1="21" y1="14" x2="3" y2="14" /> | ||
<line x1="21" y1="18" x2="7" y2="18" /> | ||
</svg> | ||
); | ||
} | ||
|
||
function BoldIcon(props: React.ComponentProps<'svg'>) { | ||
return ( | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
width="24" | ||
height="24" | ||
viewBox="0 0 24 24" | ||
{...props} | ||
> | ||
<path d="M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z" /> | ||
<path d="M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z" /> | ||
</svg> | ||
); | ||
} | ||
|
||
function ItalicsIcon(props: React.ComponentProps<'svg'>) { | ||
return ( | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
width="24" | ||
height="24" | ||
viewBox="0 0 24 24" | ||
{...props} | ||
> | ||
<line x1="19" y1="4" x2="10" y2="4" /> | ||
<line x1="14" y1="20" x2="5" y2="20" /> | ||
<line x1="15" y1="4" x2="9" y2="20" /> | ||
</svg> | ||
); | ||
} | ||
|
||
function UnderlineIcon(props: React.ComponentProps<'svg'>) { | ||
return ( | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
width="24" | ||
height="24" | ||
viewBox="0 0 24 24" | ||
{...props} | ||
> | ||
<path d="M6 3v7a6 6 0 0 0 6 6 6 6 0 0 0 6-6V3" /> | ||
<line x1="4" y1="21" x2="20" y2="21" /> | ||
</svg> | ||
); | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it a bit sketchy to need a component to have to check another somewhat-arbitrary component's context?