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

refactor(catalog): storybook for each package & composed storybook #25

Merged
merged 40 commits into from
Sep 1, 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
9c70405
Stencil controls + react wrapper + LERNA
alebinson Jul 28, 2020
b333cbc
few task are added in package.json
alebinson Jul 28, 2020
cb033ef
Material React wrappers
Aug 3, 2020
4a5fcb8
react core components compiled and partially used
alebinson Aug 4, 2020
5bce657
control usage in conflicts-ui
Aug 5, 2020
9015934
theming priniples start
Aug 6, 2020
5ba2ed6
controls integratoin. styling
Aug 10, 2020
63bb259
typography config and usage
Aug 11, 2020
10b122f
refactor(catalog): storybook for each package & composed storybook
rannyeli Aug 11, 2020
3536f31
fix(lint): linting integrated
Aug 12, 2020
b6e4b1f
fix(linting): react components
Aug 13, 2020
1427a1f
fix(compilation): core components
Aug 16, 2020
725500a
fix(lerna): more published packages
Aug 16, 2020
4aa8c2d
fix(publish): task added
Aug 16, 2020
09cdbfc
fix(lerna): tasks
Aug 16, 2020
fd40bdd
fix(lerna): package.json
Aug 16, 2020
ceac5b2
chore(publish): publish %s [ci skip]
Aug 16, 2020
1caf8c7
fix(index): lerna
Aug 16, 2020
f445ee2
fix(lerna): index
Aug 16, 2020
0312325
chore(publish): publish %s
Aug 16, 2020
2b8c936
fix(rename): mc prefix removed
Aug 16, 2020
ee59b13
fix(pkg): core
Aug 17, 2020
3f71462
Merge branch 'master' of https://github.com/MapColonies/shared-compon…
Aug 17, 2020
aab448f
fix(storybook): unneeded files
Aug 17, 2020
b0e4595
fix(rename): demoapps
Aug 17, 2020
6113a9b
fix(cleanup): unneeded storybooks remains
Aug 17, 2020
b625388
fix(pkg): script added
Aug 17, 2020
02e659d
chore(release): version bumped 1.0.0
Aug 17, 2020
bf51776
fix(readme): updated
Aug 17, 2020
edc2cb5
chore(publish): publish [by user]
Aug 17, 2020
ee29115
fix(prettier): all code is prettified
Aug 18, 2020
86ea34b
fix(prcomments): fixed
Aug 18, 2020
9ed4985
fix(tests): added tests infrastructure
rannyeli Aug 18, 2020
af28c51
Merge branch 'mc-wc-ui-components' of https://github.com/MapColonies/…
rannyeli Aug 18, 2020
5277aaa
Merge pull request #28 from MapColonies/run-tests
rannyeli Aug 18, 2020
0d93497
Merge branch 'mc-wc-ui-components' of https://github.com/MapColonies/…
rannyeli Aug 23, 2020
670c8ae
fix(composed storybook): updated storybook
rannyeli Aug 24, 2020
0bfa4d1
feat(react-core): added stories
rannyeli Aug 27, 2020
3d47424
fix(catalog): fixed react-core docs
rannyeli Aug 27, 2020
9390b9e
Merge remote-tracking branch 'origin/master' into catalog
rannyeli Sep 1, 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: 20 additions & 0 deletions .storybook/Welcome.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react';
import { Typography } from '@map-colonies/react-core/dist/typography';
import '@map-colonies/react-core/dist/typography/styles';

export default {
title: 'Welcome'
};

export const ToCatalog = () => <div>
<Typography tag="div" style={{ margin: '16px 0' }} use="headline3">
Welcome to Map Colonies Catalog
</Typography><br/>
<Typography tag="div" style={{ margin: '16px 0' }} use="subtitle1">
Shared components for Map Colonies organization.
</Typography>
</div>;

ToCatalog.story = {
name: 'to Catalog',
};
21 changes: 21 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module.exports = {
stories: ['./Welcome.stories.js'],
addons: [
'@storybook/addon-storysource',
'@storybook/addon-actions',
'@storybook/addon-knobs',
'@storybook/addon-links',
'@storybook/addon-docs',
'storybook-dark-mode'
],
refs: {
react_components: {
title: "React Components",
url: "http://localhost:9010"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we publish story books?
http://localhost:9010 is for development

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we will publish them in the future, for now it's only for development

},
react_ui_components: {
title: "React UI Components",
url: "http://localhost:9011"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we publish story books?
http://localhost:9010 is for development

}
}
};
6 changes: 6 additions & 0 deletions .storybook/manager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { addons } from '@storybook/addons';
import theme from './theme';

addons.setConfig({
theme,
});
9 changes: 9 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from "react";
import { addParameters } from '@storybook/react';
import { themes } from '@storybook/theming';

addParameters({
docs: {
theme: themes.dark,
},
});
9 changes: 9 additions & 0 deletions .storybook/theme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { create } from '@storybook/theming';
import logo from '../public/assets/logo.png';

export default create({
base: 'light',

brandTitle: 'Map Colonies-Catalog',
brandImage: logo,
});
15 changes: 15 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@
"start:reactstencildemo": "cd demoapp-stencil && yarn start",
"start:reactdemo": "cd demoapp-react && yarn start",

"storybook:react-core": "lerna exec --scope @map-colonies/react-core -- yarn storybook",
"storybook:react": "lerna exec --scope @map-colonies/react-components -- yarn storybook",
"storybook": "start-storybook -p 9009 -s public",
"build-storybook": "build-storybook -s public",

"test:react-core": "lerna exec --scope @map-colonies/react-core -- yarn test:nowatch",
"test:react": "lerna exec --scope @map-colonies/react-components -- yarn test:nowatch",
"test:all": "yarn test:react-core && yarn test:react",
Expand All @@ -60,6 +65,16 @@
"prettier:check": "prettier --check ."
},
"devDependencies": {
"@storybook/addon-actions": "^6.0.21",
"@storybook/addon-docs": "^6.0.21",
"@storybook/addon-knobs": "^6.0.21",
"@storybook/addon-links": "^6.0.21",
"@storybook/addon-storysource": "^6.0.21",
"@storybook/addons": "^6.0.21",
"@storybook/preset-create-react-app": "^3.1.4",
"@storybook/react": "^6.0.21",
"@storybook/theming": "^6.0.21",
"storybook-dark-mode": "^1.0.0",
"@commitlint/cli": "^9.1.1",
"@commitlint/config-conventional": "^9.1.1",
"@map-colonies/eslint-config": "^1.0.3",
Expand Down
12 changes: 12 additions & 0 deletions packages/react-components/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
stories: ['../src/**/*.stories.tsx'],
addons: [
'@storybook/preset-create-react-app',
'@storybook/addon-storysource',
'@storybook/addon-actions',
'@storybook/addon-knobs',
'@storybook/addon-links',
'@storybook/addon-docs',
'storybook-dark-mode'
],
};
6 changes: 6 additions & 0 deletions packages/react-components/.storybook/manager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { addons } from '@storybook/addons';
import theme from './theme';

addons.setConfig({
theme,
});
10 changes: 10 additions & 0 deletions packages/react-components/.storybook/preview-head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<style>
#story--map--basic {
height: 300px;
position: relative;
}
#story--map--with-drawer {
height: 300px;
position: relative;
}
</style>
20 changes: 20 additions & 0 deletions packages/react-components/.storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from "react";
import { addParameters, addDecorator } from '@storybook/react';
import { ThemeProvider, Themes } from '@map-colonies/react-core';
import { themes } from '@storybook/theming';
import { useDarkMode } from 'storybook-dark-mode';
import '@map-colonies/react-core/dist/rmwc/styles';

addParameters({
docs: {
theme: themes.dark,
},
});

addDecorator((story) => {
const prefersDarkMode = useDarkMode();
const theme = prefersDarkMode ? Themes.darkTheme : Themes.lightTheme;
return <ThemeProvider options={theme}>
{story()}
</ThemeProvider>
});
9 changes: 9 additions & 0 deletions packages/react-components/.storybook/theme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { create } from '@storybook/theming';
import logo from '../../../public/assets/logo.png';

export default create({
base: 'light',

brandTitle: 'Map Colonies-Catalog',
brandImage: logo,
});
11 changes: 2 additions & 9 deletions packages/react-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
"test:nowatch": "react-scripts test --coverage --watchAll=false --reporters='default' --reporters='jest-html-reporters'",
"eject": "react-scripts eject",
"postbuild": "copyfiles -u 2 -e \"**/*.ts\" -e \"**/*.tsx\" \"src/lib/**/*\" dist",
"storybook": "start-storybook -p 9010 -s public",
"build-storybook": "build-storybook -s public",
"eslint-check": "npx eslint . --ext .ts,.tsx"
},
"browserslist": {
Expand All @@ -64,15 +66,6 @@
]
},
"devDependencies": {
"@storybook/addon-actions": "^5.3.19",
"@storybook/addon-docs": "^5.3.19",
"@storybook/addon-knobs": "^5.3.19",
"@storybook/addon-links": "^5.3.19",
"@storybook/addon-storysource": "^5.3.19",
"@storybook/addons": "^5.3.19",
"@storybook/preset-create-react-app": "^3.1.4",
"@storybook/react": "^5.3.19",
"@storybook/theming": "^5.3.19",
"@types/enzyme": "^3.10.5",
"@types/enzyme-adapter-react-16": "^1.0.6",
"@types/react-test-renderer": "^16.9.2",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';
import { action } from '@storybook/addon-actions';
import { DateTimeRangePicker } from '../date-range-picker';

export default {
title: 'Picker',
component: DateTimeRangePicker,
};

export const DateTime = () => <DateTimeRangePicker onChange={action('date changed')}/>;

DateTime.story = {
name: 'Date time range',
};
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const useStyle = makeStyles((theme: Theme) =>
map: {
height: '100%',
width: '100%',
position: 'fixed',
position: 'absolute',
},
absolute: {
position: 'absolute',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from 'react';
import { ContainerMap } from '../container-map';
import { MapFilterContainer } from '../map-filter-container';
import { action } from '@storybook/addon-actions';

export default {
title: 'Map',
component: ContainerMap,
parameters: {
layout: 'fullscreen'
}
};

const mapDivStyle = {
"height": "100%",
"width": "100%",
"position": "absolute" as const
};
export const Basic = () => <div style={mapDivStyle}>
<ContainerMap onPolygonSelection={action('shape selected')}/>
</div>;

export const withDrawer = () => <MapFilterContainer
handlePolygonReset={action('vector source cleared')}
handlePolygonSelected={action('shape selected')}/>;

withDrawer.story = {
name: 'with Drawer',
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React, { useState } from 'react';
import { PolygonSelectionUi } from '../polygon-selection-ui';
import { action } from '@storybook/addon-actions';
import { DrawType } from '../../models';

export default {
title: 'Select',
component: PolygonSelectionUi,
};

export const PolygonBox = () => {
const [active, setActive] = useState(false);

const handleStartDraw = (type: DrawType) => {
setActive(true);
action('draw started')(type);
};

const handleCancelDraw = () => {
setActive(false);
action('draw canceled')();
};

return <PolygonSelectionUi
isSelectionEnabled={active}
onStartDraw={handleStartDraw}
onCancelDraw={handleCancelDraw}
onReset={action('cleared')}/>;
}

PolygonBox.story = {
name: 'Shape',
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import React, { useState } from 'react';
import { SmartTable, CellMetadata } from '..';
import { button } from '@storybook/addon-knobs';
import { action } from '@storybook/addon-actions';

export default {
title: 'Smart Table',
component: SmartTable,
};

interface Person {
firstName: string;
lastName: string;
age: number;
birthday: string;
}

const metadata: CellMetadata<Person>[] = [
{
id: "firstName",
label: "First Name",
disablePadding: false,
numeric: false,
},
{
id: "lastName",
label: "Last Name",
disablePadding: false,
numeric: false,
},
{
id: "age",
label: "Age",
disablePadding: false,
numeric: true,
},
{
id: "birthday",
label: "Birthday",
disablePadding: false,
numeric: false,
},
];

const persons:Person[] = [
{
firstName: "Dan",
lastName: "Walker",
age: 24,
birthday: "8-3-1996"
},
{
firstName: "Emily",
lastName: "Jhonson",
age: 45,
birthday: "13-5-1975"
},
{
firstName: "Ron",
lastName: "Elen",
age: 13,
birthday: "7-7-2007"
},
{
firstName: "Michael",
lastName: "Wall",
age: 60,
birthday: "28-9-1960"
}
];

const getRandomPerson = () => persons[Math.floor(Math.random() * persons.length)];

interface TableStroyProps {
numberOfItems: number;
}

const TableStory: React.FC<TableStroyProps> = (props) => {
const [rowsPerPage, setRowsPerPage] = useState(5);
const [page, setPage] = useState(0);
const [items, setItems] = useState([...new Array(props.numberOfItems)].map(getRandomPerson));

button("ADD ITEM", () => setItems([...items, getRandomPerson()]));
button("REMOVE ITEM", () => setItems(items.slice(0, -1))); //remove last
button("CLEAR TABLE", () => setItems([]));

return <SmartTable
rowsPerPage={rowsPerPage as (5 | 10)}
handleChangePage={(e, newPage) => setPage(newPage)}
handleChangeRowsPerPage={(e) => setRowsPerPage(+e.target.value)}
page={page}
count={items.length}
items={items}
isCollapseable={true}
onRequestSort={action('sort requested')}
cellsMetadata={metadata}
onRowSelected={action('row selected')}
isDense={true}/>
};

export const Small = () => <TableStory numberOfItems={4}/>
export const Large = () => <TableStory numberOfItems={60}/>
Loading