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

Merge lastest changes to master #198

Merged
merged 40 commits into from
Sep 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
973a90d
Modify drawer using link component from router dom
huayunh Aug 23, 2020
eed9d54
Update change log
huayunh Aug 23, 2020
61dfcfb
Add react router dom to dev dep
huayunh Aug 23, 2020
17cb415
Hide title on collapse
huayunh Aug 23, 2020
4c49fcb
Hide subtitle too
huayunh Aug 23, 2020
aa9971c
Update changelog wording
huayunh Aug 24, 2020
89a6f6f
Tweak clsx implementation
huayunh Aug 24, 2020
616726a
Remove react router dom; Add component prop to info list item
huayunh Aug 24, 2020
442941c
Update docs
huayunh Aug 24, 2020
528fef6
Merge branch 'dev' into feature/drawer-component
huayunh Aug 24, 2020
bdb5a19
Merge branch 'dev' into bug/178
huayunh Sep 1, 2020
d98c52e
Remove root yarn.lock
huayunh Sep 1, 2020
85c9fff
Use drawer context
huayunh Sep 1, 2020
226ca2c
Take out the drawer context null check
huayunh Sep 1, 2020
89c0a57
Update according to pr
huayunh Sep 1, 2020
b097c9a
Merge branch 'dev' into feature/drawer-component
huayunh Sep 1, 2020
cadc915
Remove the dev dependencies for the router dom
huayunh Sep 1, 2020
f2a3ec0
Add width knob
emclaug2 Sep 1, 2020
db2acc2
Add border radius around heroBanner
emclaug2 Sep 1, 2020
620d2a1
Lighten the gray
emclaug2 Sep 1, 2020
c8d81f6
Update lock; push for comments
huayunh Sep 1, 2020
4909d7a
Update drawer doc
huayunh Sep 1, 2020
f5d716d
Increase min width to 350
emclaug2 Sep 1, 2020
4d2f426
Merge pull request #192 from pxblue/feature/banner-width-knob
huayunh Sep 1, 2020
b1b2e47
Remove the unnecessary classes
huayunh Sep 2, 2020
08e2e3f
Merge pull request #188 from pxblue/bug/178
joebochill Sep 2, 2020
a092c8d
Remove react-router-dom
huayunh Sep 3, 2020
98bfcdb
Update yarn lock too
huayunh Sep 3, 2020
4df0cc4
Fix icons that should not be flipped
huayunh Sep 4, 2020
40be9c4
Lint code
huayunh Sep 4, 2020
631b3a9
Shut up linter
huayunh Sep 4, 2020
b741e76
Merge pull request #187 from pxblue/feature/drawer-component
joebochill Sep 4, 2020
581b549
Shovel get direction fn to global util
huayunh Sep 4, 2020
a856b96
Merge pull request #194 from pxblue/bug/flip-icon
joebochill Sep 4, 2020
e59cb46
Icon size should be 96px
emclaug2 Sep 4, 2020
33cd3bb
Update docs to use 96px
emclaug2 Sep 4, 2020
f2bbd6f
Update docs/EmptyState.md
EvanMcLaughlin-eaton Sep 8, 2020
f77564a
Merge pull request #195 from pxblue/feature/update-empty-state-icon-size
joebochill Sep 9, 2020
fa85795
Set ILI subtitle to black 500
joebochill Sep 29, 2020
36eae0a
Bump version
joebochill Sep 29, 2020
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
20 changes: 16 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
# Change Log
# Changelog

## v4.1.1

### Changed

- Hides Drawer Nav Item's title when the `<Drawer>` collapses in the `persistent` variant
- Improved some icon flipping logic for RTL

## v4.1.0

- Fixes RTL support issues in the `<DrawerLayout>`/`<Drawer>`
- Fixes an issue with text wrapping in the `<InfoListItem>` subtitle
- Fixes an issue with hover color alpha channel in `<InfoListItem>`
### Added

- Adds `iconAlign` prop to `<InfoListItem>` to align icon left (default), center or right
- Adds optional prop to the `<DrawerHeader>` to add a bottom divider
- Adds `<DropdownToolbar>` component

### Fixed

- Fixes RTL support issues in the `<DrawerLayout>`/`<Drawer>`
- Fixes an issue with text wrapping in the `<InfoListItem>` subtitle
- Fixes an issue with hover color alpha channel in `<InfoListItem>`

## v4.0.2

- Updates several prop types to `ReactNode` to support wider range of input values.
Expand Down
2 changes: 1 addition & 1 deletion components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pxblue/react-components",
"version": "4.1.0",
"version": "4.1.1",
"description": "React components for PX Blue applications",
"scripts": {
"test": "jest src",
Expand Down
11 changes: 7 additions & 4 deletions components/src/core/Drawer/Drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import clsx from 'clsx';
import PropTypes from 'prop-types';
import { InfoListItemProps as BaseInfoListItemProps } from '../InfoListItem';
import { useDrawerLayout } from '../DrawerLayout/contexts/DrawerLayoutContextProvider';
import { DrawerContext } from './DrawerContext';

const useStyles = makeStyles({
paper: {
Expand Down Expand Up @@ -282,14 +283,16 @@ const DrawerRenderer: React.ForwardRefRenderFunction<unknown, DrawerComponentPro
{
minHeight: '100%',
width: containerWidth,
transition: 'width 175ms cubic-bezier(.4, 0, .2, 1)',
transition: theme.transitions.create('width'),
},
drawerProps.style
)}
>
<div className={clsx(defaultClasses.content, classes.content)} style={{ width: contentWidth }}>
{getDrawerContents()}
</div>
<DrawerContext.Provider value={{ isOpen: isDrawerOpen() }}>
<div className={clsx(defaultClasses.content, classes.content)} style={{ width: contentWidth }}>
{getDrawerContents()}
</div>
</DrawerContext.Provider>
</Drawer>
);
};
Expand Down
9 changes: 9 additions & 0 deletions components/src/core/Drawer/DrawerContext.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { createContext, useContext } from 'react';

type DrawerContextType = {
isOpen: boolean;
};

export const DrawerContext = createContext<DrawerContextType>({ isOpen: true });

export const useDrawerContext = (): DrawerContextType => useContext(DrawerContext);
22 changes: 21 additions & 1 deletion components/src/core/Drawer/DrawerNavItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import clsx from 'clsx';
import { PXBlueDrawerInheritableProperties } from './Drawer';
import { DrawerNavGroupProps } from './DrawerNavGroup';
import { InfoListItem } from '../InfoListItem';
import { useDrawerContext } from './DrawerContext';

export type NavItem = {
// icon on the left
Expand Down Expand Up @@ -97,6 +98,15 @@ const useStyles = makeStyles((theme: Theme) =>
nestedTitle: {
fontWeight: 400,
},
noIconTitle: {
opacity: 0,
transition: theme.transitions.create('opacity'),
'&$drawerOpen': {
opacity: 1,
transition: theme.transitions.create('opacity'),
},
},
drawerOpen: {},
})
);

Expand All @@ -112,6 +122,7 @@ const DrawerNavItemRender: React.ForwardRefRenderFunction<unknown, DrawerNavItem

const defaultClasses = useStyles(props);
const theme = useTheme();
const { isOpen } = useDrawerContext();

const primary50Color = theme.palette.primary.light;
const { activeItem, classes, nestedDivider } = navGroupProps;
Expand Down Expand Up @@ -199,7 +210,16 @@ const DrawerNavItemRender: React.ForwardRefRenderFunction<unknown, DrawerNavItem
const active = activeItem === itemID;
const infoListItemClasses = {
root: defaultClasses.infoListItem,
title: depth > 0 ? clsx(defaultClasses.nestedTitle, classes.nestedTitle) : '',
title: clsx({
[defaultClasses.nestedTitle]: depth > 0,
[classes.nestedTitle]: depth > 0,
[defaultClasses.noIconTitle]: hidePadding && !icon,
[defaultClasses.drawerOpen]: isOpen,
}),
subtitle: clsx({
[defaultClasses.noIconTitle]: hidePadding && !icon,
[defaultClasses.drawerOpen]: isOpen,
}),
};

return (
Expand Down
2 changes: 1 addition & 1 deletion components/src/core/EmptyState/EmptyState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const useStyles = makeStyles((theme) => ({
icon: {
marginBottom: theme.spacing(2),
display: 'flex',
fontSize: 100,
fontSize: 96,
},
actions: {
marginTop: theme.spacing(1),
Expand Down
1 change: 1 addition & 0 deletions components/src/core/InfoListItem/InfoListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ const InfoListItemRender: React.ForwardRefRenderFunction<unknown, InfoListItemPr
}}
secondaryTypographyProps={{
variant: 'subtitle2',
color: 'textPrimary',
}}
/>
{getRightComponent()}
Expand Down
2 changes: 1 addition & 1 deletion demos/showcase
4 changes: 4 additions & 0 deletions demos/storybook/src/utils.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { StoryFnReactReturnType } from '@storybook/react/dist/client/preview/types';
import React from 'react';
import { COMPONENT_SECTION_NAME, README_STORY_NAME } from './constants';
import { getDirection } from '@pxblue/storybook-rtl-addon';

let banner: HTMLElement;

Expand Down Expand Up @@ -95,3 +96,6 @@ export const getReadMe = (name: string): any => {
});
return md;
};

export const getLeftToRightIconTransform = (): any =>
getDirection() === 'rtl' ? { transform: 'scaleX(-1)' } : undefined;
3 changes: 2 additions & 1 deletion demos/storybook/stories/channel-value/with-fontSize.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import * as Colors from '@pxblue/colors';
import { ChannelValue } from '@pxblue/react-components';
import { number } from '@storybook/addon-knobs';
import { StoryFnReactReturnType } from '@storybook/react/dist/client/preview/types';
import { getLeftToRightIconTransform } from '../../src/utils';
import React from 'react';

export const withFontSize = (): StoryFnReactReturnType => (
<ChannelValue
value={'123'}
units={'hz'}
icon={<Trend htmlColor={Colors.red[500]} />}
icon={<Trend htmlColor={Colors.red[500]} style={getLeftToRightIconTransform()} />}
fontSize={number('fontSize', 30)}
/>
);
Expand Down
13 changes: 9 additions & 4 deletions demos/storybook/stories/channel-value/with-full-config.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
import React from 'react';
import Trend from '@material-ui/icons/TrendingUp';
import * as Colors from '@pxblue/colors';
import { ChannelValue } from '@pxblue/react-components';
import { boolean, color, number, text } from '@storybook/addon-knobs';
import { StoryFnReactReturnType } from '@storybook/react/dist/client/preview/types';
import React from 'react';
import { WITH_FULL_CONFIG_STORY_NAME } from '../../src/constants';
import { StoryFnReactReturnType } from '@storybook/react/dist/client/preview/types';
import { boolean, color, number, text } from '@storybook/addon-knobs';
import { getLeftToRightIconTransform } from '../../src/utils';

export const withFullConfig = (): StoryFnReactReturnType => {
const value = text('value', '123');
const units = text('units', 'hz');
const textColor = color('color', Colors.red[500]);
const iconColor = color('icon.htmlColor', Colors.black[500]);
const icon = boolean('Show Icon', true) ? <Trend htmlColor={iconColor} /> : undefined;
const icon = boolean('Show Icon', true) ? (
<Trend htmlColor={iconColor} style={getLeftToRightIconTransform()} />
) : (
undefined
);
const fontSize = number('fontSize', 30);
const prefix = boolean('prefix', false);

Expand Down
7 changes: 6 additions & 1 deletion demos/storybook/stories/channel-value/with-icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@ import * as Colors from '@pxblue/colors';
import { ChannelValue } from '@pxblue/react-components';
import { color } from '@storybook/addon-knobs';
import { StoryFnReactReturnType } from '@storybook/react/dist/client/preview/types';
import { getLeftToRightIconTransform } from '../../src/utils';
import React from 'react';

export const withIcon = (): StoryFnReactReturnType => (
<ChannelValue value={'123'} units={'hz'} icon={<Trend htmlColor={color('icon.htmlColor', Colors.red[500])} />} />
<ChannelValue
value={'123'}
units={'hz'}
icon={<Trend htmlColor={color('icon.htmlColor', Colors.red[500])} style={getLeftToRightIconTransform()} />}
/>
);

withIcon.story = { name: 'with icon' };
8 changes: 4 additions & 4 deletions demos/storybook/stories/drawer/with-basic-config.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Accessibility, Menu, NotificationsActive, PermIdentity, Today, Dashboard, Toc } from '@material-ui/icons';
import { Accessibility, Menu, NotificationsActive, Person, Today, Dashboard, LocalLibrary } from '@material-ui/icons';
import { Drawer, DrawerBody, DrawerHeader, DrawerNavGroup, NavItem } from '@pxblue/react-components';
import { boolean, text } from '@storybook/addon-knobs';
import { StoryFnReactReturnType } from '@storybook/react/dist/client/preview/types';
Expand All @@ -10,7 +10,7 @@ export const navGroupItems1: NavItem[] = [
{
title: 'Identity Management',
itemID: '1',
icon: <PermIdentity />,
icon: <Person />,
},
{
title: 'Calendar',
Expand All @@ -36,9 +36,9 @@ export const navGroupItems2: NavItem[] = [
icon: <Dashboard />,
},
{
title: 'Timeline',
title: 'Manuals',
itemID: '2-2',
icon: <Toc />,
icon: <LocalLibrary />,
},
];

Expand Down
5 changes: 3 additions & 2 deletions demos/storybook/stories/drawer/with-full-config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { boolean, color, number, select, text } from '@storybook/addon-knobs';
import { StoryFnReactReturnType } from '@storybook/react/dist/client/preview/types';
import React from 'react';
import { WITH_FULL_CONFIG_STORY_NAME } from '../../src/constants';
import { getLeftToRightIconTransform } from '../../src/utils';
import { DrawerStoryContext } from './util';

const EatonLogo = require('../../assets/EatonLogo.svg');
Expand Down Expand Up @@ -218,7 +219,7 @@ export const withFullConfig = (context: DrawerStoryContext): StoryFnReactReturnT
onClick: (): void => {
context.store.set({ selected: schedule });
},
icon: <AirportShuttle />,
icon: <AirportShuttle style={getLeftToRightIconTransform()} />,
},
];

Expand All @@ -238,7 +239,7 @@ export const withFullConfig = (context: DrawerStoryContext): StoryFnReactReturnT
onClick: (): void => {
context.store.set({ selected: agreement });
},
icon: <SendIcon />,
icon: <SendIcon style={getLeftToRightIconTransform()} />,
},
{
title: accessibility,
Expand Down
9 changes: 5 additions & 4 deletions demos/storybook/stories/empty-state/with-basic-usage.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import React from 'react';
import { NotListedLocation } from '@material-ui/icons';
import { EmptyState } from '@pxblue/react-components';
import { text } from '@storybook/addon-knobs';
import { StoryFnReactReturnType } from '@storybook/react/dist/client/preview/types';
import React from 'react';
import { WITH_MIN_PROPS_STORY_NAME } from '../../src/constants';
import { StoryFnReactReturnType } from '@storybook/react/dist/client/preview/types';
import { getLeftToRightIconTransform } from '../../src/utils';
import { text } from '@storybook/addon-knobs';

export const withBasicUsage = (): StoryFnReactReturnType => (
<EmptyState
icon={<NotListedLocation fontSize={'inherit'} style={{ marginBottom: '0' }} />}
icon={<NotListedLocation fontSize={'inherit'} style={getLeftToRightIconTransform()} />}
title={text('title', 'Location Unknown')}
/>
);
Expand Down
3 changes: 2 additions & 1 deletion demos/storybook/stories/empty-state/with-full-config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { EmptyState } from '@pxblue/react-components';
import { action } from '@storybook/addon-actions';
import { text } from '@storybook/addon-knobs';
import { StoryFnReactReturnType } from '@storybook/react/dist/client/preview/types';
import { getLeftToRightIconTransform } from '../../src/utils';
import React from 'react';
import { WITH_FULL_CONFIG_STORY_NAME } from '../../src/constants';

Expand All @@ -13,7 +14,7 @@ export const withFullConfig = (): StoryFnReactReturnType => {
const actionText = text('Action Text', 'Learn More');
return (
<EmptyState
icon={<TrendingUpIcon fontSize={'inherit'} style={{ marginBottom: '0' }} />}
icon={<TrendingUpIcon fontSize={'inherit'} style={getLeftToRightIconTransform()} />}
title={title}
description={description}
actions={
Expand Down
7 changes: 6 additions & 1 deletion demos/storybook/stories/hero/within-a-HeroBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ export const inBanner = (): StoryFnReactReturnType => {
/>,
];
const numberDisplayed = number('count', 4, { range: true, min: 0, max: 4, step: 1 });
return <HeroBanner style={{ width: numberDisplayed * 100 }}>{heroes.slice(0, numberDisplayed)}</HeroBanner>;
const bannerWidth = number('width', 400, { range: true, min: 350, max: 600, step: 50 });
return (
<HeroBanner style={{ width: bannerWidth, border: `solid 1px ${Colors.gray[200]}`, borderRadius: 4 }}>
{heroes.slice(0, numberDisplayed)}
</HeroBanner>
);
};

inBanner.story = { name: 'within a Hero Banner' };
5 changes: 3 additions & 2 deletions demos/storybook/stories/user-menu/with-basic-usage.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React from 'react';
import { Avatar } from '@material-ui/core';
import { Email, ExitToApp, Settings } from '@material-ui/icons';
import { UserMenu, UserMenuItem } from '@pxblue/react-components';
import { action } from '@storybook/addon-actions';
import { text } from '@storybook/addon-knobs';
import { StoryFnReactReturnType } from '@storybook/react/dist/client/preview/types';
import React from 'react';
import { WITH_MIN_PROPS_STORY_NAME } from '../../src/constants';
import { getLeftToRightIconTransform } from '../../src/utils';

const menuItems: UserMenuItem[] = [
{
Expand All @@ -20,7 +21,7 @@ const menuItems: UserMenuItem[] = [
},
{
title: 'Log Out',
icon: <ExitToApp />,
icon: <ExitToApp style={getLeftToRightIconTransform()} />,
onClick: action("click 'Log Out'"),
},
];
Expand Down
6 changes: 4 additions & 2 deletions demos/storybook/stories/user-menu/within-a-toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { AppBar, Avatar, makeStyles, Toolbar, Typography } from '@material-ui/co
import { Spacer, UserMenu, UserMenuItem } from '@pxblue/react-components';
import { action } from '@storybook/addon-actions';
import { StoryFnReactReturnType } from '@storybook/react/dist/client/preview/types';
import { getDirection } from '@pxblue/storybook-rtl-addon';
import { getLeftToRightIconTransform } from '../../src/utils';
import React from 'react';
import * as Colors from '@pxblue/colors';
import { Email, ExitToApp, Settings } from '@material-ui/icons';
Expand All @@ -16,7 +18,7 @@ export const withinToolbar = (): StoryFnReactReturnType => {
title: {
color: Colors.gray[600],
fontSize: 12,
textAlign: 'right',
textAlign: getDirection() === 'rtl' ? 'left' : 'right',
},
});

Expand All @@ -37,7 +39,7 @@ export const withinToolbar = (): StoryFnReactReturnType => {
itemID: '3',
title: 'Log Out',
divider: true,
icon: <ExitToApp />,
icon: <ExitToApp style={getLeftToRightIconTransform()} />,
onClick: action("click 'Log Out'"),
},
{
Expand Down
Loading