Skip to content
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

UI: Update every icon for v7 design #18809

Merged
merged 25 commits into from
Aug 17, 2022
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
36ad747
Initial icon update
MichaelArestad Jul 26, 2022
1bf946a
Tweak type requirement
MichaelArestad Jul 28, 2022
d33222e
Updated Icons to be more explicit thanks to Jono
MichaelArestad Aug 1, 2022
a65d6a7
Fix typescript errors - props Shaun on this one
MichaelArestad Aug 3, 2022
d12dfc4
Removed unused bindin
MichaelArestad Aug 3, 2022
cbe28f9
Fixed missing chevrons, fixed icon size in buttons, fixed alert icon …
MichaelArestad Aug 3, 2022
c1b108e
Fixed button sizes and made slight tweak to alignment of icon in Acco…
MichaelArestad Aug 4, 2022
9694d53
Made alert icon slightly smaller in release_notes.tsx
MichaelArestad Aug 4, 2022
4f2d6d4
Added Operating System icons and updated rule
MichaelArestad Aug 4, 2022
c693d12
Fix MenuButton size
MichaelArestad Aug 4, 2022
b482044
Remove icons list from docs FAQ
MichaelArestad Aug 4, 2022
9a42687
Update NotificationItem and updated a handful of icons to match the D…
MichaelArestad Aug 5, 2022
59f9f49
Merge branch 'next' into pr/18809
domyen Aug 11, 2022
3f1f574
Merge branch 'next' into update-every-icon
yannbf Aug 12, 2022
6d1585a
update stories and snapshots
yannbf Aug 12, 2022
f72bbaa
Embiggen the sidebar icons by 2px
domyen Aug 12, 2022
3de325f
Viewport copyedit from "rotate" to "swap" dimensions
domyen Aug 12, 2022
1320ba9
Use the appropriate share icon in Docs Preview Toolbar
domyen Aug 12, 2022
2237d97
Revert "Embiggen the sidebar icons by 2px"
domyen Aug 12, 2022
24da49e
Revert "Viewport copyedit from "rotate" to "swap" dimensions"
domyen Aug 12, 2022
f65602f
Revert "Use the appropriate share icon in Docs Preview Toolbar"
domyen Aug 12, 2022
bb3a2d8
Add icon embed to FAQ
domyen Aug 13, 2022
f1fb9af
Updated bookmark, bookmarkhollow, document, and folder icons
MichaelArestad Aug 16, 2022
162463e
Review feedback
shilman Aug 17, 2022
820b8e4
Merge branch 'next' into update-every-icon
shilman Aug 17, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion code/addons/a11y/src/components/Report/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export const Item = (props: ItemProps) => {
<Wrapper>
<HeaderBar onClick={() => onToggle(!open)} role="button">
<Icon
icon="chevrondown"
icon="arrowdown"
color="#9DA5AB"
style={{
transform: `rotate(${open ? 0 : -90}deg)`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ const ErrorIcon = styled(Icons)(({ theme }) => ({
opacity: 0.8,
marginRight: 6,
marginLeft: 2,
marginTop: 1,
marginTop: 4,
}));

const ErrorTooltip = styled.div(({ theme }) => ({
Expand Down
2 changes: 1 addition & 1 deletion code/addons/interactions/src/components/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const ListItem: React.FC<ListItemProps> = ({ item }) => {
<Wrapper>
<HeaderBar onClick={() => onToggle(!open)} role="button">
<Icon
icon="chevrondown"
icon="arrowdown"
color={convert(themes.light).appBorderColor}
style={{
transform: `rotate(${open ? 0 : -90}deg)`,
Expand Down
4 changes: 3 additions & 1 deletion code/addons/interactions/src/components/StatusIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import { styled } from '@storybook/theming';
import { transparentize } from 'polished';
import localTheme from '../theme';

export interface StatusIconProps extends IconsProps {
export interface StatusIconProps {
status: Call['status'];
useSymbol?: IconsProps['useSymbol'];
className?: string;
}

const {
Expand Down
2 changes: 1 addition & 1 deletion code/addons/jest/src/components/Result.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export function Result(props: ResultProps) {
<HeaderBar onClick={onToggle} role="button" status={status}>
{status === `failed` ? (
<Icon
icon="chevrondown"
icon="arrowdown"
color={convert(themes.light).color.mediumdark}
style={{
transform: `rotate(${isOpen ? 0 : -90}deg)`,
Expand Down
2 changes: 1 addition & 1 deletion code/addons/toolbars/src/components/ToolbarMenuButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Icons, IconButton, IconsProps } from '@storybook/components';
interface ToolbarMenuButtonProps {
active: boolean;
title: string;
icon: IconsProps['icon'] | '';
icon?: IconsProps['icon'];
description: string;
onClick?: () => void;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const ToolbarMenuListItem = ({
onClick,
currentValue,
}: ToolbarMenuListItemProps) => {
const Icon = <Icons style={{ opacity: 1 }} icon={icon} />;
const Icon = icon && <Icons style={{ opacity: 1 }} icon={icon} />;
const hasContent = left || right || title;

const Item: ListItem = {
Expand Down
2 changes: 1 addition & 1 deletion code/addons/toolbars/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export interface NormalizedToolbarConfig {
/** The label to show for this toolbar item */
title?: string;
/** Choose an icon to show for this toolbar item */
icon?: IconsProps['icon'];
icon: IconsProps['icon'];
/** Set to true to prevent default update of icon to match any present selected items icon */
preventDynamicIcon?: boolean;
items: ToolbarItem[];
Expand Down
10 changes: 5 additions & 5 deletions code/lib/components/src/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ const ButtonWrapper = styled.button<{

svg: {
display: 'inline-block',
height: small ? 14 : 16,
width: small ? 14 : 16,
height: small ? 12 : 14,
width: small ? 12 : 14,

verticalAlign: 'top',
marginRight: small ? 4 : 6,
marginTop: small ? -1 : -2,
marginBottom: small ? -1 : -2,
marginTop: small ? 0 : -1,
yannbf marked this conversation as resolved.
Show resolved Hide resolved
marginBottom: small ? 0 : -1,

/* Necessary for js mouse events to not glitch out when hovering on svgs */
pointerEvents: 'none',
Expand All @@ -74,7 +74,7 @@ const ButtonWrapper = styled.button<{
display: 'block',
margin: 0,
},
...(small ? { padding: 9 } : { padding: 12 }),
...(small ? { padding: 10 } : { padding: 13 }),
}
: {},
({ theme, primary, secondary, gray }) => {
Expand Down
120 changes: 66 additions & 54 deletions code/lib/components/src/icon/icon.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,77 +1,89 @@
import React from 'react';
import { styled } from '@storybook/theming';
import { storiesOf } from '@storybook/react';
import { styled, css } from '@storybook/theming';

import { Icons } from './icon';
import { icons, IconKey } from './icons';

const Meta = styled.div({
color: '#333',
fontSize: 12,
});
const Meta = styled.div`
color: #666;
font-size: 12px;
`;

interface ItemProps {
minimal?: boolean;
}
const Item = styled.li<{ minimal?: boolean }>`
display: inline-flex;
flex-direction: row;
align-items: center;
flex: 0 1 16%;
min-width: 120px;
margin: 16px;

const Item = styled.div<ItemProps>(
{
display: 'inline-flex',
flexDirection: 'row',
alignItems: 'center',
flex: '0 1 20%',
minWidth: 120,
svg {
margin-right: 6px;
width: 14px;
height: 14px;
}

padding: '0px 7.5px 20px',
${(props) =>
props.minimal &&
css`
flex: none;
min-width: auto;
padding: 0;
margin: 16px;

'& svg': {
marginRight: 10,
width: 24,
height: 24,
},
},
({ minimal }) =>
minimal
? {
flex: 'none',
minWidth: 'auto',
padding: 0,
background: '#fff',
border: '1px solid #666',
svg {
display: block;
margin-right: 0;
width: 14px;
height: 14px;
}
`};
`;

'& svg': {
display: 'block',
marginRight: 0,
width: 48,
height: 48,
},
}
: {}
);
const List = styled.ul`
display: flex;
flex-flow: row wrap;
list-style: none;
padding: 0;
margin: 0;
`;

const Header = styled.h2`
font-size: 16px;
margin: 16px;
`;

const List = styled.div({
display: 'flex',
flexFlow: 'row wrap',
});
export default {
title: 'Basics/Icon',
component: Icons,
};

const list = Object.keys(icons).sort() as IconKey[];
export const Basic = (args) => <Icons {...args} />;
Basic.args = { icon: 'watch' };

storiesOf('Basics/Icon', module)
.add('labels', () => (
export const Labels = () => (
<>
<Header>{Object.keys(icons).length} icons</Header>
<List>
{list.map((key) => (
{Object.keys(icons).map((key) => (
<Item key={key}>
<Icons icon={key} /> <Meta>{key}</Meta>
<Icons icon={key as IconKey} aria-hidden />
<Meta>{key}</Meta>
</Item>
))}
</List>
))
.add('no labels', () => (
</>
);

export const NoLabels = () => (
<>
<Header>{Object.keys(icons).length} icons</Header>
<List>
{list.map((key) => (
{Object.keys(icons).map((key) => (
<Item minimal key={key}>
<Icons icon={key} />
<Icons icon={key as IconKey} aria-label={key} />
</Item>
))}
</List>
));
</>
);
44 changes: 26 additions & 18 deletions code/lib/components/src/icon/icon.tsx
Original file line number Diff line number Diff line change
@@ -1,39 +1,47 @@
import React, { ComponentProps, memo } from 'react';
import React, { FunctionComponent, ComponentProps, memo } from 'react';
import { styled } from '@storybook/theming';
import icons, { IconKey } from './icons';
import { icons, IconKey } from './icons';

import Svg from './svg';
const Svg = styled.svg`
display: inline-block;
shape-rendering: inherit;
transform: translate3d(0, 0, 0);
vertical-align: middle;

const Path = styled.path({
fill: 'currentColor',
});
path {
fill: currentColor;
}
`;

export interface IconsProps extends ComponentProps<typeof Svg> {
icon?: IconKey;
symbol?: IconKey;
icon: IconType;
useSymbol?: boolean;
shilman marked this conversation as resolved.
Show resolved Hide resolved
}

// TODO: if we can resize the 1024 to 20, we can remove the size attributes
export const Icons = memo<IconsProps>(({ icon, symbol, ...props }) => (
<Svg viewBox="0 0 1024 1024" {...props}>
{symbol ? <use xlinkHref={`#icon--${symbol}`} /> : <Path d={icons[icon]} />}
</Svg>
));
export const Icons: FunctionComponent<IconsProps> = ({ icon, useSymbol, ...props }: IconsProps) => {
return (
<Svg viewBox="0 0 14 14" width="14px" height="14px" {...props}>
{useSymbol ? <use xlinkHref={`#icon--${icon}`} /> : icons[icon]}
</Svg>
);
};

export type IconType = keyof typeof icons;

export interface SymbolsProps extends ComponentProps<typeof Svg> {
icons?: IconKey[];
}

export const Symbols = memo<SymbolsProps>(({ icons: keys = Object.keys(icons) }) => (
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This component differed from the one in the Design System in that there was an effort to make a symbol instead of using SVGs directly (sort of like a sprite). I left that functionality in tact here, but I am unsure if it is necessary. Thoughts?

<svg
xmlns="http://www.w3.org/2000/svg"
<Svg
viewBox="0 0 14 14"
style={{ position: 'absolute', width: 0, height: 0 }}
data-chromatic="ignore"
>
{keys.map((key: IconKey) => (
<symbol id={`icon--${key}`} key={key}>
<Path d={icons[key]} />
{icons[key]}
</symbol>
))}
</svg>
</Svg>
));
Loading