-
-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Content 7: Tooltip and Slider (#980)
- Loading branch information
Showing
17 changed files
with
477 additions
and
14 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
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
36 changes: 36 additions & 0 deletions
36
docs/src/app/new/(content)/components/slider/demos/hero/css-modules/index.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,36 @@ | ||
.Control { | ||
box-sizing: border-box; | ||
display: flex; | ||
align-items: center; | ||
width: 14rem; | ||
padding-block: 0.75rem; | ||
} | ||
|
||
.Track { | ||
width: 100%; | ||
background-color: var(--color-gray-200); | ||
box-shadow: inset 0 0 0 1px var(--color-gray-200); | ||
height: 0.25rem; | ||
border-radius: 0.25rem; | ||
position: relative; | ||
} | ||
|
||
.Indicator { | ||
/* TODO remove relative when position absolute is removed */ | ||
position: relative !important; | ||
display: block; | ||
border-radius: 0.25rem; | ||
background-color: var(--color-gray-700); | ||
} | ||
|
||
.Thumb { | ||
width: 1rem; | ||
height: 1rem; | ||
border-radius: 100%; | ||
background-color: white; | ||
outline: 1px solid var(--color-gray-300); | ||
|
||
&:focus-visible { | ||
outline: 2px solid var(--color-blue); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
docs/src/app/new/(content)/components/slider/demos/hero/css-modules/index.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,16 @@ | ||
import * as React from 'react'; | ||
import { Slider } from '@base-ui-components/react/slider'; | ||
import styles from './index.module.css'; | ||
|
||
export default function ExampleSlider() { | ||
return ( | ||
<Slider.Root defaultValue={25}> | ||
<Slider.Control className={styles.Control}> | ||
<Slider.Track className={styles.Track}> | ||
<Slider.Indicator className={styles.Indicator} /> | ||
<Slider.Thumb className={styles.Thumb} /> | ||
</Slider.Track> | ||
</Slider.Control> | ||
</Slider.Root> | ||
); | ||
} |
3 changes: 3 additions & 0 deletions
3
docs/src/app/new/(content)/components/slider/demos/hero/index.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,3 @@ | ||
'use client'; | ||
export { default as CssModules } from './css-modules'; | ||
export { default as Tailwind } from './tailwind'; |
16 changes: 16 additions & 0 deletions
16
docs/src/app/new/(content)/components/slider/demos/hero/tailwind/index.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,16 @@ | ||
import * as React from 'react'; | ||
import { Slider } from '@base-ui-components/react/slider'; | ||
|
||
export default function ExampleSlider() { | ||
return ( | ||
<Slider.Root defaultValue={25}> | ||
<Slider.Control className="flex w-56 items-center px-2 py-3"> | ||
<Slider.Track className="relative h-1 w-full rounded bg-gray-200 shadow-[inset_0_0_0_1px] shadow-gray-200"> | ||
{/* TODO remove relative when position absolute is removed */} | ||
<Slider.Indicator className="!relative block rounded bg-gray-700" /> | ||
<Slider.Thumb className="size-4 rounded-full bg-white outline outline-gray-300 focus-visible:outline-2 focus-visible:outline-blue-800" /> | ||
</Slider.Track> | ||
</Slider.Control> | ||
</Slider.Root> | ||
); | ||
} |
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,29 @@ | ||
# Slider | ||
|
||
<Subtitle>An easily stylable range input.</Subtitle> | ||
<Meta | ||
name="description" | ||
content="A high-quality, unstyled React slider component that works like a range input and is easy to style." | ||
/> | ||
|
||
<Demo path="./demos/hero" /> | ||
|
||
## API reference | ||
|
||
Import the component and place its parts the following way: | ||
|
||
```jsx title="Anatomy" | ||
import { Slider } from '@base-ui-components/react/slider'; | ||
|
||
<Slider.Root> | ||
<Slider.Output /> | ||
<Slider.Control> | ||
<Slider.Track> | ||
<Slider.Indicator /> | ||
<Slider.Thumb /> | ||
</Slider.Track> | ||
</Slider.Control> | ||
</Slider.Root>; | ||
``` | ||
|
||
<Reference component="Slider" parts="Root, Output, Control, Track, Indicator, Thumb" /> |
123 changes: 123 additions & 0 deletions
123
docs/src/app/new/(content)/components/tooltip/demos/hero/css-modules/index.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,123 @@ | ||
.Group { | ||
display: flex; | ||
border: 1px solid var(--color-gray-200); | ||
background-color: var(--color-gray-50); | ||
border-radius: 0.375rem; | ||
padding: 0.125rem; | ||
} | ||
|
||
.GhostButton { | ||
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-900); | ||
user-select: none; | ||
|
||
&[data-popup-open] { | ||
background-color: var(--color-gray-100); | ||
} | ||
|
||
&: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); | ||
} | ||
} | ||
|
||
.Icon { | ||
width: 1rem; | ||
height: 1rem; | ||
} | ||
|
||
.Popup { | ||
box-sizing: border-box; | ||
font-size: 0.9375rem; | ||
line-height: 1.375rem; | ||
display: flex; | ||
flex-direction: column; | ||
padding: 0.25rem 0.5rem; | ||
border-radius: 0.375rem; | ||
background-color: canvas; | ||
transform-origin: var(--transform-origin); | ||
transition: | ||
transform 150ms, | ||
opacity 150ms; | ||
|
||
&[data-starting-style], | ||
&[data-ending-style] { | ||
opacity: 0; | ||
transform: scale(0.9); | ||
} | ||
|
||
&[data-instant] { | ||
transition-duration: 0ms; | ||
} | ||
|
||
@media (prefers-color-scheme: light) { | ||
outline: 1px solid var(--color-gray-200); | ||
box-shadow: | ||
0px 10px 15px -3px var(--color-gray-200), | ||
0px 4px 6px -4px var(--color-gray-200); | ||
} | ||
|
||
@media (prefers-color-scheme: dark) { | ||
outline: 1px solid var(--color-gray-300); | ||
outline-offset: -1px; | ||
} | ||
} | ||
|
||
.Arrow { | ||
display: flex; | ||
|
||
&[data-side='top'] { | ||
bottom: -8px; | ||
rotate: 180deg; | ||
} | ||
&[data-side='bottom'] { | ||
top: -8px; | ||
rotate: 0deg; | ||
} | ||
&[data-side='left'] { | ||
right: -13px; | ||
rotate: 90deg; | ||
} | ||
&[data-side='right'] { | ||
left: -13px; | ||
rotate: -90deg; | ||
} | ||
} | ||
|
||
.ArrowFill { | ||
fill: canvas; | ||
} | ||
|
||
.ArrowOuterStroke { | ||
@media (prefers-color-scheme: light) { | ||
fill: var(--color-gray-200); | ||
} | ||
} | ||
|
||
.ArrowInnerStroke { | ||
@media (prefers-color-scheme: dark) { | ||
fill: var(--color-gray-300); | ||
} | ||
} |
Oops, something went wrong.