From f3e90f35ba5f56bbcf1fa3ffff66e7756790d6ee Mon Sep 17 00:00:00 2001 From: Albert Yu Date: Thu, 12 Sep 2024 21:19:36 +0800 Subject: [PATCH] Update demos --- docs/data/components/slider/RangeSlider.js | 188 ++++-------------- docs/data/components/slider/RangeSlider.tsx | 188 ++++-------------- docs/data/components/slider/RtlSlider.js | 153 +++----------- docs/data/components/slider/RtlSlider.tsx | 151 +++----------- .../components/slider/RtlSlider.tsx.preview | 10 - .../css-modules/index.js | 133 +------------ .../css-modules/index.tsx | 133 +------------ .../css-modules/index.tsx.preview | 16 ++ docs/data/components/slider/VerticalSlider.js | 134 +------------ .../data/components/slider/VerticalSlider.tsx | 134 +------------ docs/data/components/slider/styles.module.css | 99 +++++++++ .../components/slider/vertical.module.css | 106 ++++++++++ 12 files changed, 390 insertions(+), 1055 deletions(-) delete mode 100644 docs/data/components/slider/RtlSlider.tsx.preview create mode 100644 docs/data/components/slider/UnstyledSliderIntroduction/css-modules/index.tsx.preview create mode 100644 docs/data/components/slider/styles.module.css create mode 100644 docs/data/components/slider/vertical.module.css diff --git a/docs/data/components/slider/RangeSlider.js b/docs/data/components/slider/RangeSlider.js index f8b56822b3..ece3baa604 100644 --- a/docs/data/components/slider/RangeSlider.js +++ b/docs/data/components/slider/RangeSlider.js @@ -1,7 +1,8 @@ 'use client'; import * as React from 'react'; -import { styled, useTheme, Box } from '@mui/system'; -import * as BaseSlider from '@base_ui/react/Slider'; +import { useTheme } from '@mui/system'; +import * as Slider from '@base_ui/react/Slider'; +import classes from './styles.module.css'; export default function RangeSlider() { // Replace this with your app logic for determining dark mode @@ -9,160 +10,59 @@ export default function RangeSlider() { const [value, setValue] = React.useState([20, 37]); return ( - {/* controlled: */} - - - - - - - - - - - + {/* + we can't use a + + + Uncontrolled Range + + + + + + + + + + + ); } -const grey = { - 50: '#F3F6F9', - 100: '#E5EAF2', - 200: '#DAE2ED', - 300: '#C7D0DD', - 400: '#B0B8C4', - 500: '#9DA8B7', - 600: '#6B7A90', - 700: '#434D5B', - 800: '#303740', - 900: '#1C2025', -}; - function useIsDarkMode() { const theme = useTheme(); return theme.palette.mode === 'dark'; } - -const Slider = styled(BaseSlider.Root)` - font-family: 'IBM Plex Sans', sans-serif; - font-size: 1rem; - width: 100%; - align-items: center; - position: relative; - -webkit-tap-highlight-color: transparent; - display: grid; - grid-template-columns: 1fr 1fr; - gap: 1rem; -`; - -const SliderOutput = styled(BaseSlider.Output)` - text-align: right; -`; - -const SliderControl = styled(BaseSlider.Control)` - grid-column: 1/3; - display: flex; - align-items: center; - position: relative; - width: 100%; - height: 16px; - border-radius: 9999px; - touch-action: none; - - &[data-disabled] { - cursor: not-allowed; - } -`; - -const SliderTrack = styled(BaseSlider.Track)` - width: 100%; - height: 2px; - border-radius: 9999px; - background-color: ${grey[400]}; - touch-action: none; - - .dark & { - background-color: ${grey[700]}; - } -`; - -const SliderIndicator = styled(BaseSlider.Indicator)` - border-radius: 9999px; - background-color: black; - - .dark & { - background-color: ${grey[100]}; - } -`; - -const SliderThumb = styled(BaseSlider.Thumb)` - position: absolute; - width: 16px; - height: 16px; - box-sizing: border-box; - border-radius: 50%; - background-color: black; - transform: translateX(-50%); - touch-action: none; - - &:focus-visible { - outline: 2px solid black; - outline-offset: 2px; - } - - .dark & { - background-color: ${grey[300]}; - } - - .dark &:focus-visible { - outline-color: ${grey[300]}; - outline-width: 1px; - outline-offset: 3px; - } - - &[data-dragging='true'] { - background-color: pink; - } - - &[data-disabled], - .dark &[data-disabled] { - background-color: ${grey[600]}; - } - - .dark &[data-dragging='true'] { - background-color: pink; - } -`; - -// we can't use a