-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[docs][base] Add Tailwind CSS + plain CSS demo on the Menu page #38618
Merged
Merged
Changes from all commits
Commits
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
There are no files selected for viewing
163 changes: 163 additions & 0 deletions
163
docs/data/base/components/menu/MenuIntroduction/css/index.js
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,163 @@ | ||
import * as React from 'react'; | ||
import { Menu } from '@mui/base/Menu'; | ||
import { MenuItem, menuItemClasses } from '@mui/base/MenuItem'; | ||
import { MenuButton } from '@mui/base/MenuButton'; | ||
import { Dropdown } from '@mui/base/Dropdown'; | ||
import { useTheme } from '@mui/system'; | ||
|
||
export default function MenuIntroduction() { | ||
const createHandleMenuClick = (menuItem) => { | ||
return () => { | ||
console.log(`Clicked on ${menuItem}`); | ||
}; | ||
}; | ||
|
||
return ( | ||
<Dropdown> | ||
<MenuButton className="TriggerButtonIntroduction">My account</MenuButton> | ||
|
||
<Menu | ||
className="CustomMenuIntroduction" | ||
slotProps={{ | ||
listbox: { className: 'CustomMenuIntroduction--listbox' }, | ||
}} | ||
> | ||
<MenuItem | ||
className="CustomMenuIntroduction--item" | ||
onClick={createHandleMenuClick('Profile')} | ||
> | ||
Profile | ||
</MenuItem> | ||
<MenuItem | ||
className="CustomMenuIntroduction--item" | ||
onClick={createHandleMenuClick('Language settings')} | ||
> | ||
Language settings | ||
</MenuItem> | ||
<MenuItem | ||
className="CustomMenuIntroduction--item" | ||
onClick={createHandleMenuClick('Log out')} | ||
> | ||
Log out | ||
</MenuItem> | ||
</Menu> | ||
<Styles /> | ||
</Dropdown> | ||
); | ||
} | ||
|
||
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 ( | ||
<style>{` | ||
.CustomMenuIntroduction--listbox { | ||
font-family: IBM Plex Sans, sans-serif; | ||
font-size: 0.875rem; | ||
box-sizing: border-box; | ||
padding: 6px; | ||
margin: 12px 0; | ||
min-width: 200px; | ||
border-radius: 12px; | ||
overflow: auto; | ||
outline: 0px; | ||
background: ${isDarkMode ? grey[900] : '#fff'}; | ||
border: 1px solid ${isDarkMode ? grey[700] : grey[200]}; | ||
color: ${isDarkMode ? grey[300] : grey[900]}; | ||
box-shadow: 0px 4px 30px ${isDarkMode ? grey[900] : grey[200]}; | ||
} | ||
|
||
.CustomMenuIntroduction--item { | ||
list-style: none; | ||
padding: 8px; | ||
border-radius: 8px; | ||
cursor: default; | ||
user-select: none; | ||
} | ||
|
||
.CustomMenuIntroduction--item:last-of-type { | ||
border-bottom: none; | ||
} | ||
|
||
.CustomMenuIntroduction--item.${menuItemClasses.focusVisible} { | ||
outline: 3px solid ${isDarkMode ? cyan[600] : cyan[200]}; | ||
background-color: ${isDarkMode ? grey[800] : grey[100]}; | ||
color: ${isDarkMode ? grey[300] : grey[900]}; | ||
} | ||
|
||
.CustomMenuIntroduction--item.${menuItemClasses.disabled} { | ||
color: ${isDarkMode ? grey[700] : grey[400]}; | ||
} | ||
|
||
.CustomMenuIntroduction--item:hover:not(.${menuItemClasses.disabled}) { | ||
background-color: ${isDarkMode ? cyan[800] : cyan[50]}; | ||
color: ${isDarkMode ? grey[300] : grey[900]}; | ||
} | ||
|
||
.TriggerButtonIntroduction { | ||
font-family: IBM Plex Sans, sans-serif; | ||
font-size: 0.875rem; | ||
font-weight: 600; | ||
box-sizing: border-box; | ||
min-height: calc(1.5em + 22px); | ||
border-radius: 12px; | ||
padding: 8px 14px; | ||
line-height: 1.5; | ||
background: ${isDarkMode ? grey[900] : '#fff'}; | ||
cursor: pointer; | ||
border: 1px solid ${isDarkMode ? grey[700] : grey[200]}; | ||
color: ${isDarkMode ? grey[300] : grey[900]}; | ||
|
||
transition-property: all; | ||
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); | ||
transition-duration: 120ms; | ||
} | ||
|
||
.TriggerButtonIntroduction:hover { | ||
background: ${isDarkMode ? grey[800] : grey[50]}; | ||
border-color: ${isDarkMode ? grey[600] : grey[300]}; | ||
} | ||
|
||
.TriggerButtonIntroduction:focus-visible { | ||
border-color: ${cyan[400]}; | ||
outline: 3px solid ${isDarkMode ? cyan[500] : cyan[200]}; | ||
} | ||
|
||
.CustomMenuIntroduction { | ||
z-index: 1; | ||
} | ||
`}</style> | ||
); | ||
} |
163 changes: 163 additions & 0 deletions
163
docs/data/base/components/menu/MenuIntroduction/css/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,163 @@ | ||
import * as React from 'react'; | ||
import { Menu } from '@mui/base/Menu'; | ||
import { MenuItem, menuItemClasses } from '@mui/base/MenuItem'; | ||
import { MenuButton } from '@mui/base/MenuButton'; | ||
import { Dropdown } from '@mui/base/Dropdown'; | ||
import { useTheme } from '@mui/system'; | ||
|
||
export default function MenuIntroduction() { | ||
const createHandleMenuClick = (menuItem: string) => { | ||
return () => { | ||
console.log(`Clicked on ${menuItem}`); | ||
}; | ||
}; | ||
|
||
return ( | ||
<Dropdown> | ||
<MenuButton className="TriggerButtonIntroduction">My account</MenuButton> | ||
|
||
<Menu | ||
className="CustomMenuIntroduction" | ||
slotProps={{ | ||
listbox: { className: 'CustomMenuIntroduction--listbox' }, | ||
}} | ||
> | ||
<MenuItem | ||
className="CustomMenuIntroduction--item" | ||
onClick={createHandleMenuClick('Profile')} | ||
> | ||
Profile | ||
</MenuItem> | ||
<MenuItem | ||
className="CustomMenuIntroduction--item" | ||
onClick={createHandleMenuClick('Language settings')} | ||
> | ||
Language settings | ||
</MenuItem> | ||
<MenuItem | ||
className="CustomMenuIntroduction--item" | ||
onClick={createHandleMenuClick('Log out')} | ||
> | ||
Log out | ||
</MenuItem> | ||
</Menu> | ||
<Styles /> | ||
</Dropdown> | ||
); | ||
} | ||
|
||
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 ( | ||
<style>{` | ||
.CustomMenuIntroduction--listbox { | ||
font-family: IBM Plex Sans, sans-serif; | ||
font-size: 0.875rem; | ||
box-sizing: border-box; | ||
padding: 6px; | ||
margin: 12px 0; | ||
min-width: 200px; | ||
border-radius: 12px; | ||
overflow: auto; | ||
outline: 0px; | ||
background: ${isDarkMode ? grey[900] : '#fff'}; | ||
border: 1px solid ${isDarkMode ? grey[700] : grey[200]}; | ||
color: ${isDarkMode ? grey[300] : grey[900]}; | ||
box-shadow: 0px 4px 30px ${isDarkMode ? grey[900] : grey[200]}; | ||
} | ||
|
||
.CustomMenuIntroduction--item { | ||
list-style: none; | ||
padding: 8px; | ||
border-radius: 8px; | ||
cursor: default; | ||
user-select: none; | ||
} | ||
|
||
.CustomMenuIntroduction--item:last-of-type { | ||
border-bottom: none; | ||
} | ||
|
||
.CustomMenuIntroduction--item.${menuItemClasses.focusVisible} { | ||
outline: 3px solid ${isDarkMode ? cyan[600] : cyan[200]}; | ||
background-color: ${isDarkMode ? grey[800] : grey[100]}; | ||
color: ${isDarkMode ? grey[300] : grey[900]}; | ||
} | ||
|
||
.CustomMenuIntroduction--item.${menuItemClasses.disabled} { | ||
color: ${isDarkMode ? grey[700] : grey[400]}; | ||
} | ||
|
||
.CustomMenuIntroduction--item:hover:not(.${menuItemClasses.disabled}) { | ||
background-color: ${isDarkMode ? cyan[800] : cyan[50]}; | ||
color: ${isDarkMode ? grey[300] : grey[900]}; | ||
} | ||
|
||
.TriggerButtonIntroduction { | ||
font-family: IBM Plex Sans, sans-serif; | ||
font-size: 0.875rem; | ||
font-weight: 600; | ||
box-sizing: border-box; | ||
min-height: calc(1.5em + 22px); | ||
border-radius: 12px; | ||
padding: 8px 14px; | ||
line-height: 1.5; | ||
background: ${isDarkMode ? grey[900] : '#fff'}; | ||
cursor: pointer; | ||
border: 1px solid ${isDarkMode ? grey[700] : grey[200]}; | ||
color: ${isDarkMode ? grey[300] : grey[900]}; | ||
|
||
transition-property: all; | ||
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); | ||
transition-duration: 120ms; | ||
} | ||
|
||
.TriggerButtonIntroduction:hover { | ||
background: ${isDarkMode ? grey[800] : grey[50]}; | ||
border-color: ${isDarkMode ? grey[600] : grey[300]}; | ||
} | ||
|
||
.TriggerButtonIntroduction:focus-visible { | ||
border-color: ${cyan[400]}; | ||
outline: 3px solid ${isDarkMode ? cyan[500] : cyan[200]}; | ||
} | ||
|
||
.CustomMenuIntroduction { | ||
z-index: 1; | ||
} | ||
`}</style> | ||
); | ||
} |
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
Oops, something went wrong.
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.
Nice catch! :)