-
Notifications
You must be signed in to change notification settings - Fork 97
feat(avatars): adds light/dark mode colors #1852
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f7e8416
feat(avatars): adds light/dark mode colors
geotrev de96047
chore: corrects foreground of status indicator
geotrev ad87795
chore: use transient props
geotrev 462d84d
chore: design color fix
geotrev 9cce9ad
chore: code review changes
geotrev 9c2c239
chore: code review
geotrev 403bf68
chore: code review getStatusColor
geotrev 1b86420
chore: use transparent fallback
geotrev 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
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -5,93 +5,80 @@ | |
| * found at http://www.apache.org/licenses/LICENSE-2.0. | ||
| */ | ||
|
|
||
| import React, { useState } from 'react'; | ||
| import { Story } from '@storybook/react'; | ||
| import Icon from '@zendeskgarden/svg-icons/src/16/chevron-down-stroke.svg'; | ||
| import { PALETTE } from '@zendeskgarden/react-theming'; | ||
| import React, { useCallback, useState } from 'react'; | ||
| import { StoryFn } from '@storybook/react'; | ||
| import { getColor } from '@zendeskgarden/react-theming'; | ||
| import { Grid } from '@zendeskgarden/react-grid'; | ||
| import { | ||
| Dropdown, | ||
| Trigger, | ||
| Menu, | ||
| MediaItem, | ||
| MediaFigure, | ||
| MediaBody, | ||
| ItemMeta | ||
| } from '@zendeskgarden/react-dropdowns.legacy'; | ||
| import { Button } from '@zendeskgarden/react-buttons'; | ||
| import { Avatar } from '@zendeskgarden/react-avatars'; | ||
| import { Menu, Item } from '@zendeskgarden/react-dropdowns'; | ||
| import { Avatar, IAvatarProps } from '@zendeskgarden/react-avatars'; | ||
| import { useTheme } from 'styled-components'; | ||
|
|
||
| export const MenuStory: Story = ({ isCompact }) => { | ||
| const [highlightedItem, setHighlightedItem] = useState<number | null>(); | ||
| const [isOpen, setIsOpen] = useState<boolean | undefined>(); | ||
| const items: { | ||
| value: string; | ||
| label: string; | ||
| avatarProps: IAvatarProps; | ||
| }[] = [ | ||
| { | ||
| value: 'linden', | ||
| label: 'Linden', | ||
| avatarProps: { | ||
| status: 'away', | ||
| badge: undefined | ||
| } | ||
| }, | ||
| { | ||
| value: 'reed', | ||
| label: 'Reed', | ||
| avatarProps: { | ||
| status: 'available', | ||
| badge: undefined | ||
| } | ||
| }, | ||
| { | ||
| value: 'sage', | ||
| label: 'Sage', | ||
| avatarProps: { | ||
| status: undefined, | ||
| badge: '3' | ||
| } | ||
| } | ||
| ]; | ||
|
|
||
| export const MenuStory: StoryFn = ({ isCompact }) => { | ||
| const [highlightedValue, setHighlightedValue] = useState<string | null>(); | ||
| const theme = useTheme(); | ||
| const surfaceColor = getColor({ variable: 'background.raised', theme }); | ||
| const highlightedColor = getColor({ variable: 'background.primary', theme }); | ||
|
|
||
| const onChange = useCallback(({ focusedValue }: { focusedValue?: string | null }) => { | ||
| focusedValue !== undefined && setHighlightedValue(focusedValue); | ||
| }, []); | ||
|
|
||
| return ( | ||
| <Grid> | ||
| <Grid.Row style={{ height: 'calc(100vh - 80px)' }}> | ||
| <Grid.Col textAlign="center" alignSelf="center"> | ||
| <Dropdown | ||
| onStateChange={changes => { | ||
| setHighlightedItem(changes.highlightedIndex); | ||
| Object.prototype.hasOwnProperty.call(changes, 'isOpen') && setIsOpen(changes.isOpen); | ||
| }} | ||
| > | ||
| <Trigger> | ||
| <Button size={isCompact && 'small'}> | ||
| Demo | ||
| <Button.EndIcon isRotated={isOpen}> | ||
| <Icon /> | ||
| </Button.EndIcon> | ||
| </Button> | ||
| </Trigger> | ||
| <Menu isCompact={isCompact}> | ||
| <MediaItem value="linden"> | ||
| <MediaFigure> | ||
| <Avatar | ||
| size={isCompact ? 'extraextrasmall' : 'small'} | ||
| status="away" | ||
| surfaceColor={highlightedItem === 0 ? PALETTE.blue[100] : undefined} | ||
| > | ||
| <img alt="Linden" src="images/avatars/linden.png" /> | ||
| </Avatar> | ||
| </MediaFigure> | ||
| <MediaBody> | ||
| Linden | ||
| <ItemMeta>[email protected]</ItemMeta> | ||
| </MediaBody> | ||
| </MediaItem> | ||
| <MediaItem value="reed"> | ||
| <MediaFigure> | ||
| <Avatar | ||
| size={isCompact ? 'extraextrasmall' : 'small'} | ||
| status="available" | ||
| surfaceColor={highlightedItem === 1 ? PALETTE.blue[100] : undefined} | ||
| > | ||
| <img alt="Reed" src="images/avatars/reed.png" /> | ||
| </Avatar> | ||
| </MediaFigure> | ||
| <MediaBody> | ||
| Reed | ||
| <ItemMeta>[email protected]</ItemMeta> | ||
| </MediaBody> | ||
| </MediaItem> | ||
| <MediaItem value="sage"> | ||
| <MediaFigure> | ||
| <Menu button="Demo" isCompact={isCompact} onChange={onChange}> | ||
| {items.map(item => ( | ||
| <Item | ||
| key={item.value} | ||
| value={item.value} | ||
| icon={ | ||
| <Avatar | ||
| size={isCompact ? 'extraextrasmall' : 'small'} | ||
| badge="3" | ||
| surfaceColor={highlightedItem === 2 ? PALETTE.blue[100] : undefined} | ||
| status={item.avatarProps.status} | ||
| badge={item.avatarProps.badge} | ||
| surfaceColor={highlightedValue === item.value ? highlightedColor : surfaceColor} | ||
| > | ||
| <img alt="Sage" src="images/avatars/sage.png" /> | ||
| <img alt={item.label} src={`images/avatars/${item.value}.png`} /> | ||
| </Avatar> | ||
| </MediaFigure> | ||
| <MediaBody> | ||
| Sage | ||
| <ItemMeta>[email protected]</ItemMeta> | ||
| </MediaBody> | ||
| </MediaItem> | ||
| </Menu> | ||
| </Dropdown> | ||
| } | ||
| > | ||
| {item.label} | ||
| <Item.Meta>{item.value}@zendesk.garden</Item.Meta> | ||
| </Item> | ||
| ))} | ||
| </Menu> | ||
| </Grid.Col> | ||
| </Grid.Row> | ||
| </Grid> | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Uh oh!
There was an error while loading. Please reload this page.