forked from mui/base-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
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
b37dfc9
commit 52b873e
Showing
31 changed files
with
1,335 additions
and
9 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,19 @@ | ||
{ | ||
"props": { | ||
"className": { "type": { "name": "union", "description": "func<br>| string" } }, | ||
"render": { "type": { "name": "union", "description": "element<br>| func" } } | ||
}, | ||
"name": "MeterIndicator", | ||
"imports": [ | ||
"import { Meter } from '@base_ui/react/Meter';\nconst MeterIndicator = Meter.Indicator;" | ||
], | ||
"classes": [], | ||
"spread": true, | ||
"themeDefaultProps": true, | ||
"muiName": "MeterIndicator", | ||
"forwardsRefTo": "HTMLSpanElement", | ||
"filename": "/packages/mui-base/src/Meter/Indicator/MeterIndicator.tsx", | ||
"inheritance": null, | ||
"demos": "<ul><li><a href=\"/components/react-meter/\">Meter</a></li></ul>", | ||
"cssComponent": false | ||
} |
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,38 @@ | ||
{ | ||
"props": { | ||
"value": { "type": { "name": "number" }, "required": true }, | ||
"aria-label": { "type": { "name": "string" } }, | ||
"aria-labelledby": { "type": { "name": "string" } }, | ||
"aria-valuetext": { "type": { "name": "string" } }, | ||
"className": { "type": { "name": "union", "description": "func<br>| string" } }, | ||
"direction": { | ||
"type": { "name": "enum", "description": "'ltr'<br>| 'rtl'" }, | ||
"default": "'ltr'" | ||
}, | ||
"getAriaLabel": { | ||
"type": { "name": "func" }, | ||
"signature": { "type": "function(value: number) => string", "describedArgs": ["value"] } | ||
}, | ||
"getAriaValueText": { | ||
"type": { "name": "func" }, | ||
"signature": { "type": "function(value: number) => string", "describedArgs": ["value"] } | ||
}, | ||
"high": { "type": { "name": "number" }, "default": "100" }, | ||
"low": { "type": { "name": "number" }, "default": "0" }, | ||
"max": { "type": { "name": "number" }, "default": "100" }, | ||
"min": { "type": { "name": "number" }, "default": "0" }, | ||
"optimum": { "type": { "name": "number" }, "default": "50" }, | ||
"render": { "type": { "name": "union", "description": "element<br>| func" } } | ||
}, | ||
"name": "MeterRoot", | ||
"imports": ["import { Meter } from '@base_ui/react/Meter';\nconst MeterRoot = Meter.Root;"], | ||
"classes": [], | ||
"spread": true, | ||
"themeDefaultProps": true, | ||
"muiName": "MeterRoot", | ||
"forwardsRefTo": "HTMLDivElement", | ||
"filename": "/packages/mui-base/src/Meter/Root/MeterRoot.tsx", | ||
"inheritance": null, | ||
"demos": "<ul><li><a href=\"/components/react-meter/\">Meter</a></li></ul>", | ||
"cssComponent": false | ||
} |
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,17 @@ | ||
{ | ||
"props": { | ||
"className": { "type": { "name": "union", "description": "func<br>| string" } }, | ||
"render": { "type": { "name": "union", "description": "element<br>| func" } } | ||
}, | ||
"name": "MeterTrack", | ||
"imports": ["import { Meter } from '@base_ui/react/Meter';\nconst MeterTrack = Meter.Track;"], | ||
"classes": [], | ||
"spread": true, | ||
"themeDefaultProps": true, | ||
"muiName": "MeterTrack", | ||
"forwardsRefTo": "HTMLSpanElement", | ||
"filename": "/packages/mui-base/src/Meter/Track/MeterTrack.tsx", | ||
"inheritance": null, | ||
"demos": "<ul><li><a href=\"/components/react-meter/\">Meter</a></li></ul>", | ||
"cssComponent": false | ||
} |
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,35 @@ | ||
'use client'; | ||
import * as React from 'react'; | ||
import { Meter } from '@base_ui/react/Meter'; | ||
import classes from './styles.module.css'; | ||
|
||
export default function MeterIntroduction() { | ||
return ( | ||
<div className={classes.demo}> | ||
<Meter.Root className={classes.meter} value={60} aria-label="Battery Life"> | ||
<Meter.Track className={classes.track}> | ||
<BoltIcon className={classes.icon} /> | ||
<Meter.Indicator className={classes.indicator} /> | ||
</Meter.Track> | ||
</Meter.Root> | ||
</div> | ||
); | ||
} | ||
|
||
function BoltIcon(props) { | ||
return ( | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
{...props} | ||
width="24" | ||
height="24" | ||
viewBox="0 0 24 24" | ||
fill="none" | ||
> | ||
<path | ||
d="M10.67 21c-.35 0-.62-.31-.57-.66L11 14H7.5c-.88 0-.33-.75-.31-.78 1.26-2.23 3.15-5.53 5.65-9.93.1-.18.3-.29.5-.29.35 0 .62.31.57.66l-.9 6.34h3.51c.4 0 .62.19.4.66-3.29 5.74-5.2 9.09-5.75 10.05-.1.18-.29.29-.5.29z" | ||
fill="currentColor" | ||
/> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
'use client'; | ||
import * as React from 'react'; | ||
import { Meter } from '@base_ui/react/Meter'; | ||
import classes from './styles.module.css'; | ||
|
||
export default function MeterIntroduction() { | ||
return ( | ||
<div className={classes.demo}> | ||
<Meter.Root className={classes.meter} value={60} aria-label="Battery Life"> | ||
<Meter.Track className={classes.track}> | ||
<BoltIcon className={classes.icon} /> | ||
<Meter.Indicator className={classes.indicator} /> | ||
</Meter.Track> | ||
</Meter.Root> | ||
</div> | ||
); | ||
} | ||
|
||
function BoltIcon(props: React.SVGProps<SVGSVGElement>) { | ||
return ( | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
{...props} | ||
width="24" | ||
height="24" | ||
viewBox="0 0 24 24" | ||
fill="none" | ||
> | ||
<path | ||
d="M10.67 21c-.35 0-.62-.31-.57-.66L11 14H7.5c-.88 0-.33-.75-.31-.78 1.26-2.23 3.15-5.53 5.65-9.93.1-.18.3-.29.5-.29.35 0 .62.31.57.66l-.9 6.34h3.51c.4 0 .62.19.4.66-3.29 5.74-5.2 9.09-5.75 10.05-.1.18-.29.29-.5.29z" | ||
fill="currentColor" | ||
/> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<Meter.Root className={classes.meter} value={60} aria-label="Battery Life"> | ||
<Meter.Track className={classes.track}> | ||
<BoltIcon className={classes.icon} /> | ||
<Meter.Indicator className={classes.indicator} /> | ||
</Meter.Track> | ||
</Meter.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,38 @@ | ||
--- | ||
productId: base-ui | ||
title: React Meter components | ||
description: The Meter component provides a graphical display of a numeric value within a defined range | ||
components: MeterRoot, MeterTrack, MeterIndicator | ||
hooks: useMeterRoot, useMeterIndicator | ||
githubLabel: 'component: meter' | ||
waiAria: https://www.w3.org/WAI/ARIA/apg/patterns/meter/ | ||
packageName: '@base_ui/react' | ||
--- | ||
|
||
# Meter | ||
|
||
<Description /> | ||
|
||
<ComponentLinkHeader design={false} /> | ||
|
||
<Demo demo="MeterIntroduction" defaultCodeOpen="false" bg="gradient" /> | ||
|
||
## Installation | ||
|
||
<InstallationInstructions componentName="Meter" /> | ||
|
||
### Anatomy | ||
|
||
Meter | ||
|
||
- `<Meter.Root />` is a top-level component that wraps the other components. | ||
- `<Meter.Track />` renders the rail that represents the full range of possible values. | ||
- `<Meter.Indicator />` renders the filled portion of the track. | ||
|
||
```tsx | ||
<Meter.Root> | ||
<Meter.Track> | ||
<Meter.Indicator /> | ||
</Meter.Track> | ||
</Meter.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,49 @@ | ||
.demo { | ||
--icon-size: 46px; | ||
display: flex; | ||
flex-flow: row nowrap; | ||
justify-content: center; | ||
align-items: center; | ||
padding: 1rem; | ||
} | ||
|
||
.meter { | ||
display: flex; | ||
flex-flow: column nowrap; | ||
gap: 1rem; | ||
color: var(--gray-text-2); | ||
} | ||
|
||
.track { | ||
position: relative; | ||
width: 38px; | ||
height: 16px; | ||
border-radius: 5px; | ||
border: 3px solid currentColor; | ||
padding: 2px; | ||
display: flex; | ||
} | ||
|
||
.track:after { | ||
content: ''; | ||
background-color: currentColor; | ||
position: absolute; | ||
z-index: 1; | ||
top: 3px; | ||
right: -6px; | ||
width: 3px; | ||
height: 14px; | ||
border-radius: 0 6px 6px 0; | ||
} | ||
|
||
.icon { | ||
position: absolute; | ||
width: var(--icon-size); | ||
height: var(--icon-size); | ||
transform: translate(-3px, -14px); | ||
} | ||
|
||
.indicator { | ||
background-color: rgb(40, 205, 65); | ||
border-radius: 3px; | ||
} |
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
10 changes: 10 additions & 0 deletions
10
docs/data/translations/api-docs/meter-indicator/meter-indicator.json
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,10 @@ | ||
{ | ||
"componentDescription": "", | ||
"propDescriptions": { | ||
"className": { | ||
"description": "Class names applied to the element or a function that returns them based on the component's state." | ||
}, | ||
"render": { "description": "A function to customize rendering of the component." } | ||
}, | ||
"classDescriptions": {} | ||
} |
38 changes: 38 additions & 0 deletions
38
docs/data/translations/api-docs/meter-root/meter-root.json
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,38 @@ | ||
{ | ||
"componentDescription": "", | ||
"propDescriptions": { | ||
"aria-label": { "description": "The label for the Indicator component." }, | ||
"aria-labelledby": { | ||
"description": "An id or space-separated list of ids of elements that label the Indicator component." | ||
}, | ||
"aria-valuetext": { | ||
"description": "A string value that provides a human-readable text alternative for the current value of the meter indicator." | ||
}, | ||
"className": { | ||
"description": "Class names applied to the element or a function that returns them based on the component's state." | ||
}, | ||
"direction": { "description": "The direction that the meter fills towards" }, | ||
"getAriaLabel": { | ||
"description": "Accepts a function which returns a string value that provides an accessible name for the Indicator component", | ||
"typeDescriptions": { "value": "The component's value" } | ||
}, | ||
"getAriaValueText": { | ||
"description": "Accepts a function which returns a string value that provides a human-readable text alternative for the current value of the meter indicator.", | ||
"typeDescriptions": { "value": "The component's value to format" } | ||
}, | ||
"high": { | ||
"description": "Sets the lower boundary of the high end of the numeric range represented by the component. If unspecified, or greater than <code>max</code>, it will fall back to <code>max</code>." | ||
}, | ||
"low": { | ||
"description": "Sets the upper boundary of the low end of the numeric range represented by the component. If unspecified, or less than <code>min</code>, it will fall back to <code>min</code>." | ||
}, | ||
"max": { "description": "The maximum value" }, | ||
"min": { "description": "The minimum value" }, | ||
"optimum": { | ||
"description": "Indicates the optimal point in the numeric range represented by the component. If unspecified, it will fall back to the midpoint between <code>min</code> and <code>max</code>." | ||
}, | ||
"render": { "description": "A function to customize rendering of the component." }, | ||
"value": { "description": "The current value." } | ||
}, | ||
"classDescriptions": {} | ||
} |
10 changes: 10 additions & 0 deletions
10
docs/data/translations/api-docs/meter-track/meter-track.json
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,10 @@ | ||
{ | ||
"componentDescription": "", | ||
"propDescriptions": { | ||
"className": { | ||
"description": "Class names applied to the element or a function that returns them based on the component's state." | ||
}, | ||
"render": { "description": "A function to customize rendering of the component." } | ||
}, | ||
"classDescriptions": {} | ||
} |
Oops, something went wrong.