From 16dfaff405fdee91c168b271c8a138ee48285d55 Mon Sep 17 00:00:00 2001 From: Ali Sasani Babak Date: Fri, 15 Sep 2023 17:49:44 +0100 Subject: [PATCH] add css and tailwind demo for tabs component --- .../UnstyledTabsIntroduction/css/index.js | 136 ++++++++++++++++++ .../UnstyledTabsIntroduction/css/index.tsx | 136 ++++++++++++++++++ .../UnstyledTabsIntroduction.tsx.preview | 0 .../system/index.js} | 0 .../system/index.tsx} | 0 .../system/index.tsx.preview | 10 ++ .../tailwind/index.js | 103 +++++++++++++ .../tailwind/index.tsx | 85 +++++++++++ .../tailwind/index.tsx.preview | 10 ++ docs/data/base/components/tabs/tabs.md | 2 +- 10 files changed, 481 insertions(+), 1 deletion(-) create mode 100644 docs/data/base/components/tabs/UnstyledTabsIntroduction/css/index.js create mode 100644 docs/data/base/components/tabs/UnstyledTabsIntroduction/css/index.tsx rename docs/data/base/components/tabs/{ => UnstyledTabsIntroduction/system}/UnstyledTabsIntroduction.tsx.preview (100%) rename docs/data/base/components/tabs/{UnstyledTabsIntroduction.js => UnstyledTabsIntroduction/system/index.js} (100%) rename docs/data/base/components/tabs/{UnstyledTabsIntroduction.tsx => UnstyledTabsIntroduction/system/index.tsx} (100%) create mode 100644 docs/data/base/components/tabs/UnstyledTabsIntroduction/system/index.tsx.preview create mode 100644 docs/data/base/components/tabs/UnstyledTabsIntroduction/tailwind/index.js create mode 100644 docs/data/base/components/tabs/UnstyledTabsIntroduction/tailwind/index.tsx create mode 100644 docs/data/base/components/tabs/UnstyledTabsIntroduction/tailwind/index.tsx.preview diff --git a/docs/data/base/components/tabs/UnstyledTabsIntroduction/css/index.js b/docs/data/base/components/tabs/UnstyledTabsIntroduction/css/index.js new file mode 100644 index 00000000000000..f95fe3b505ec3d --- /dev/null +++ b/docs/data/base/components/tabs/UnstyledTabsIntroduction/css/index.js @@ -0,0 +1,136 @@ +import * as React from 'react'; +import { useTheme } from '@mui/system'; +import { Tabs } from '@mui/base/Tabs'; +import { TabsList } from '@mui/base/TabsList'; +import { TabPanel } from '@mui/base/TabPanel'; +import { buttonClasses } from '@mui/base/Button'; +import { Tab, tabClasses } from '@mui/base/Tab'; + +export default function UnstyledTabsIntroduction() { + return ( + + + + + My account + + + Profile + + + Language + + + + My account page + + + Profile page + + + Language page + + + + + ); +} + +const cyan = { + 50: '#E9F8FC', + 100: '#BDEBF4', + 200: '#99D8E5', + 300: '#66BACC', + 400: '#1F94AD', + 500: '#0D5463', + 600: '#094855', + 700: '#063C47', + 800: '#043039', + 900: '#022127', +}; + +const grey = { + 50: '#f6f8fa', + 100: '#eaeef2', + 200: '#d0d7de', + 300: '#afb8c1', + 400: '#8c959f', + 500: '#6e7781', + 600: '#57606a', + 700: '#424a53', + 800: '#32383f', + 900: '#24292f', +}; + +function useIsDarkMode() { + const theme = useTheme(); + return theme.palette.mode === 'dark'; +} + +function Styles() { + // Replace this with your app logic for determining dark mode + const isDarkMode = useIsDarkMode(); + return ( + + ); +} diff --git a/docs/data/base/components/tabs/UnstyledTabsIntroduction/css/index.tsx b/docs/data/base/components/tabs/UnstyledTabsIntroduction/css/index.tsx new file mode 100644 index 00000000000000..f95fe3b505ec3d --- /dev/null +++ b/docs/data/base/components/tabs/UnstyledTabsIntroduction/css/index.tsx @@ -0,0 +1,136 @@ +import * as React from 'react'; +import { useTheme } from '@mui/system'; +import { Tabs } from '@mui/base/Tabs'; +import { TabsList } from '@mui/base/TabsList'; +import { TabPanel } from '@mui/base/TabPanel'; +import { buttonClasses } from '@mui/base/Button'; +import { Tab, tabClasses } from '@mui/base/Tab'; + +export default function UnstyledTabsIntroduction() { + return ( + + + + + My account + + + Profile + + + Language + + + + My account page + + + Profile page + + + Language page + + + + + ); +} + +const cyan = { + 50: '#E9F8FC', + 100: '#BDEBF4', + 200: '#99D8E5', + 300: '#66BACC', + 400: '#1F94AD', + 500: '#0D5463', + 600: '#094855', + 700: '#063C47', + 800: '#043039', + 900: '#022127', +}; + +const grey = { + 50: '#f6f8fa', + 100: '#eaeef2', + 200: '#d0d7de', + 300: '#afb8c1', + 400: '#8c959f', + 500: '#6e7781', + 600: '#57606a', + 700: '#424a53', + 800: '#32383f', + 900: '#24292f', +}; + +function useIsDarkMode() { + const theme = useTheme(); + return theme.palette.mode === 'dark'; +} + +function Styles() { + // Replace this with your app logic for determining dark mode + const isDarkMode = useIsDarkMode(); + return ( + + ); +} diff --git a/docs/data/base/components/tabs/UnstyledTabsIntroduction.tsx.preview b/docs/data/base/components/tabs/UnstyledTabsIntroduction/system/UnstyledTabsIntroduction.tsx.preview similarity index 100% rename from docs/data/base/components/tabs/UnstyledTabsIntroduction.tsx.preview rename to docs/data/base/components/tabs/UnstyledTabsIntroduction/system/UnstyledTabsIntroduction.tsx.preview diff --git a/docs/data/base/components/tabs/UnstyledTabsIntroduction.js b/docs/data/base/components/tabs/UnstyledTabsIntroduction/system/index.js similarity index 100% rename from docs/data/base/components/tabs/UnstyledTabsIntroduction.js rename to docs/data/base/components/tabs/UnstyledTabsIntroduction/system/index.js diff --git a/docs/data/base/components/tabs/UnstyledTabsIntroduction.tsx b/docs/data/base/components/tabs/UnstyledTabsIntroduction/system/index.tsx similarity index 100% rename from docs/data/base/components/tabs/UnstyledTabsIntroduction.tsx rename to docs/data/base/components/tabs/UnstyledTabsIntroduction/system/index.tsx diff --git a/docs/data/base/components/tabs/UnstyledTabsIntroduction/system/index.tsx.preview b/docs/data/base/components/tabs/UnstyledTabsIntroduction/system/index.tsx.preview new file mode 100644 index 00000000000000..036845502e3951 --- /dev/null +++ b/docs/data/base/components/tabs/UnstyledTabsIntroduction/system/index.tsx.preview @@ -0,0 +1,10 @@ + + + My account + Profile + Language + + My account page + Profile page + Language page + \ No newline at end of file diff --git a/docs/data/base/components/tabs/UnstyledTabsIntroduction/tailwind/index.js b/docs/data/base/components/tabs/UnstyledTabsIntroduction/tailwind/index.js new file mode 100644 index 00000000000000..24fd3912593102 --- /dev/null +++ b/docs/data/base/components/tabs/UnstyledTabsIntroduction/tailwind/index.js @@ -0,0 +1,103 @@ +import * as React from 'react'; +import PropTypes from 'prop-types'; +import clsx from 'clsx'; +import { Tabs } from '@mui/base/Tabs'; +import { TabsList as BaseTabsList } from '@mui/base/TabsList'; +import { TabPanel as BaseTabPanel } from '@mui/base/TabPanel'; +import { Tab as BaseTab } from '@mui/base/Tab'; + +export default function UnstyledTabsIntroduction() { + return ( + + + My account + Profile + Language + + My account page + Profile page + Language page + + ); +} + +const resolveSlotProps = (fn, args) => (typeof fn === 'function' ? fn(args) : fn); + +const TabsList = React.forwardRef((props, ref) => { + const { className, ...other } = props; + return ( + + ); +}); + +TabsList.propTypes = { + className: PropTypes.string, +}; + +const Tab = React.forwardRef((props, ref) => { + return ( + { + const resolvedSlotProps = resolveSlotProps( + props.slotProps?.root, + ownerState, + ); + return { + ...resolvedSlotProps, + className: clsx( + `font-sans ${ + ownerState.selected + ? 'text-purple-500 bg-white' + : 'text-white bg-transparent focus:text-white hover:bg-purple-400' + } ${ + ownerState.disabled + ? 'cursor-not-allowed opacity-50' + : 'cursor-pointer' + } text-sm leading-[1.3] font-semibold w-full py-2.5 px-3 m-1.5 border-0 rounded-md flex justify-center focus:outline-0 focus:shadow-outline-purple-light`, + resolvedSlotProps?.className, + ), + }; + }, + }} + /> + ); +}); + +Tab.propTypes = { + /** + * The props used for each slot inside the Tab. + * @default {} + */ + slotProps: PropTypes.shape({ + root: PropTypes.oneOfType([PropTypes.func, PropTypes.object]), + }), +}; + +const TabPanel = React.forwardRef((props, ref) => { + const { className, ...other } = props; + return ( + + ); +}); + +TabPanel.propTypes = { + className: PropTypes.string, +}; diff --git a/docs/data/base/components/tabs/UnstyledTabsIntroduction/tailwind/index.tsx b/docs/data/base/components/tabs/UnstyledTabsIntroduction/tailwind/index.tsx new file mode 100644 index 00000000000000..e4581686c50075 --- /dev/null +++ b/docs/data/base/components/tabs/UnstyledTabsIntroduction/tailwind/index.tsx @@ -0,0 +1,85 @@ +import * as React from 'react'; +import clsx from 'clsx'; +import { Tabs } from '@mui/base/Tabs'; +import { TabsList as BaseTabsList, TabsListProps } from '@mui/base/TabsList'; +import { TabPanel as BaseTabPanel, TabPanelProps } from '@mui/base/TabPanel'; +import { Tab as BaseTab, TabProps } from '@mui/base/Tab'; + +export default function UnstyledTabsIntroduction() { + return ( + + + My account + Profile + Language + + My account page + Profile page + Language page + + ); +} + +const resolveSlotProps = (fn: any, args: any) => + typeof fn === 'function' ? fn(args) : fn; + +const TabsList = React.forwardRef((props, ref) => { + const { className, ...other } = props; + return ( + + ); +}); + +const Tab = React.forwardRef((props, ref) => { + return ( + { + const resolvedSlotProps = resolveSlotProps( + props.slotProps?.root, + ownerState, + ); + return { + ...resolvedSlotProps, + className: clsx( + `font-sans ${ + ownerState.selected + ? 'text-purple-500 bg-white' + : 'text-white bg-transparent focus:text-white hover:bg-purple-400' + } ${ + ownerState.disabled + ? 'cursor-not-allowed opacity-50' + : 'cursor-pointer' + } text-sm leading-[1.3] font-semibold w-full py-2.5 px-3 m-1.5 border-0 rounded-md flex justify-center focus:outline-0 focus:shadow-outline-purple-light`, + resolvedSlotProps?.className, + ), + }; + }, + }} + /> + ); +}); + +const TabPanel = React.forwardRef((props, ref) => { + const { className, ...other } = props; + return ( + + ); +}); diff --git a/docs/data/base/components/tabs/UnstyledTabsIntroduction/tailwind/index.tsx.preview b/docs/data/base/components/tabs/UnstyledTabsIntroduction/tailwind/index.tsx.preview new file mode 100644 index 00000000000000..4b3b0829672faf --- /dev/null +++ b/docs/data/base/components/tabs/UnstyledTabsIntroduction/tailwind/index.tsx.preview @@ -0,0 +1,10 @@ + + + My account + Profile + Language + + My account page + Profile page + Language page + \ No newline at end of file diff --git a/docs/data/base/components/tabs/tabs.md b/docs/data/base/components/tabs/tabs.md index 768a599ba7490e..c7c4a607acb732 100644 --- a/docs/data/base/components/tabs/tabs.md +++ b/docs/data/base/components/tabs/tabs.md @@ -24,7 +24,7 @@ Tabs are implemented using a collection of related components: - `` - the card that hosts the content associated with a tab. - `` - the top-level component that wraps the Tabs List and Tab Panel components so that tabs and their panels can communicate with one another. -{{"demo": "UnstyledTabsIntroduction.js", "defaultCodeOpen": false, "bg": "gradient"}} +{{"demo": "UnstyledTabsIntroduction", "defaultCodeOpen": false, "bg": "gradient"}} ## Components