Skip to content

Commit

Permalink
Merge pull request #8 from Platzi-Master-C8/develop
Browse files Browse the repository at this point in the history
Develop - Add Icons Package
  • Loading branch information
yadurani authored Dec 3, 2021
2 parents b0920d3 + 6e5276d commit 1372cb0
Show file tree
Hide file tree
Showing 87 changed files with 913 additions and 15,376 deletions.
6 changes: 6 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,11 @@ module.exports = {
'testing-library/no-node-access': 'off'
}
},
{
files: ['./packages/**/src/**/index.js', './packages/**/src/**/index.d.ts'],
'rules': {
'no-restricted-exports': 'off'
}
}
]
};
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -207,5 +207,5 @@ $RECYCLE.BIN/

# Windows shortcuts
*.lnk

yarn.lock
# End of https://www.toptal.com/developers/gitignore/api/react,node,macos,linux,windows
1 change: 1 addition & 0 deletions .storybook/preview-head.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<link href="https://fonts.googleapis.com/css2?family=Mulish:wght@300;400;500;600;700&display=swap" rel="stylesheet">
40 changes: 37 additions & 3 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,43 @@
import { ThemeProvider } from 'emotion-theming';
import { createTheme } from "@mui/material/styles";

import { THEME } from '@master-c8/theme';

const getHiredTheme = createTheme(THEME);

const getStyles = ({ __sb } = {}) => ({
display: 'flex',
flexDirection: __sb?.fd || 'column',
maxHeight: __sb?.mh || 'auto',
justifyContent: 'flex-start',
alignContent: 'flex-start',
flexWrap: 'wrap',
height: '100%',
gap: '10px 30px',
alignItems: 'center'
})

export const parameters = {
actions: { argTypesRegex: "^on[A-Z].*" },
actions: {
argTypesRegex: "^on[A-Z].*"
},
controls: {
matchers: {
color: /(background|color)$/i,
date: /Date$/,
},
},
}
}
}

export const decorators = [
(Story) => (
<ThemeProvider theme={getHiredTheme}>
<Story/>
</ThemeProvider>
),
(Story, { parameters }) => (
<div style={getStyles(parameters)}>
<Story />
</div>
),
];
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
presets: ['@babel/preset-env', '@babel/preset-react'],
presets: ['@babel/preset-env', ['@babel/preset-react', { runtime: 'automatic' }]],
};
6 changes: 4 additions & 2 deletions config/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ module.exports = {
setupFilesAfterEnv: ['<rootDir>/config/tests.config.js'],
testEnvironment: 'jsdom',
moduleNameMapper: {
'@gethired/commons': '<rootDir>/packages/components',
'@gethired/commons/*': '<rootDir>/packages/components/$1',
'@master-c8/commons': '<rootDir>/packages/components',
'@master-c8/commons/*': '<rootDir>/packages/components/$1',
'@master-c8/icons': '<rootDir>/packages/icons',
'@master-c8/icons/*': '<rootDir>/packages/icons/$1',
},
modulePathIgnorePatterns: ['dist'],
};
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"test": "jest --config ./config/jest.config.js",
"test:watch": "jest --config ./config/jest.config.js --watch-all",
"test:coverage": "jest --config ./config/jest.config.js --coverage",
"storybook": "start-storybook -p 6006",
"storybook": "start-storybook -p 6006 -c .storybook watch-css -s ./packages/components/src",
"dev": "start-storybook -p 5555",
"build-storybook": "build-storybook"
},
Expand All @@ -22,6 +22,7 @@
"@emotion/styled": "^11.6.0",
"@mui/material": "^5.2.1",
"@mui/styled-engine-sc": "^5.1.0",
"@mui/styles": "^5.2.2",
"@storybook/addon-actions": "^6.4.0",
"@storybook/addon-essentials": "^6.4.0",
"@storybook/addon-links": "^6.4.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
}
},
"dependencies": {
"@master-c8/theme": "0.1.4",
"@master-c8/theme": "0.1.3",
"@master-c8/icons": "0.1.0",
"prop-types": "15.7.2"
},
"publishConfig": {
Expand Down
22 changes: 15 additions & 7 deletions packages/components/src/ButtonExample/ButtonExample.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
import { Button } from '@mui/material';
import { ThemeProvider } from '@master-c8/theme';
import { forwardRef } from 'react';
import { Button as ButtonMui } from '@mui/material';
import PropTypes from 'prop-types';

const ButtonExample = forwardRef(function ButtonExample(props, ref) {
return <Button ref={ref} {...props} />;
});
export default ButtonExample;
const Button = ({ ...props }) => {
return (
<ButtonMui {...props}/>
);
};

Button.propTypes = {
color: PropTypes.oneOf(['primary', 'secondary']),
size: PropTypes.oneOf(['small', 'medium', 'large']),
variant: PropTypes.oneOf(['contained', 'outlined']),
};

export default Button;
60 changes: 51 additions & 9 deletions packages/components/src/ButtonExample/ButtonExample.stories.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,58 @@
import { ThemeProvider } from '@master-c8/theme';

import ButtonExample from './ButtonExample';

export default {
title: 'example/button',
title: 'Design System/Atoms/Button',
component: ButtonExample,
parameters: { __sb: { fd: 'row' } },
argTypes: {
color: {},
size: {
options: ['small', 'large'],
control: { type: 'select' },
table: {
category: 'Sizes',
},
},
},
};

const Template = (args) => <ButtonExample {...args} />;

export const Primary = Template.bind({});

Primary.args = {
children: 'BUTTON',
variant: 'contained',
};

const getListTemplate = (Component) =>
({ items, ...args }) =>
items.map((item, index) => {
return <Component key={index} {...args} {...item} />;
});

const ListTemplate = getListTemplate(ButtonExample);

export const Sizes = ListTemplate.bind({});

Sizes.args = {
items: ['small', 'medium', 'large'].map((size) => ({ size })),
children: 'BUTTON',
variant: 'contained',
color: 'primary',
};

export const Default = () => {
return (
<ThemeProvider>
<ButtonExample variant="contained">Button Dafault</ButtonExample>
</ThemeProvider>
);
export const Colors = ListTemplate.bind({});

Colors.args = {
items: ['primary', 'secondary'].map((color) => ({ color })),
children: 'BUTTON',
variant: 'contained',
};

export const Variants = ListTemplate.bind({});

Variants.args = {
items: ['contained', 'outlined'].map((variant) => ({ variant })),
children: 'BUTTON',
};
42 changes: 42 additions & 0 deletions packages/components/src/IconsStory/Icons.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import * as IconsPackage from '@master-c8/icons';

export default {
title: 'Design System/Atoms/Icons',
component: 'Icons',
parameters: { __sb: { fd: 'row' } },
argTypes: {
color: {
options: [
'primary',
'secondary',
'error',
'info',
'success',
'warning',
'inherit',
'action',
'disabled',
],
control: { type: 'select' },
table: {
category: 'Sizes',
},
},
fontSize: {
options: ['small', 'large'],
control: { type: 'select' },
table: {
category: 'Sizes',
},
},
},
};

export const Icons = (args) => {
const iconsKeyList = Object.keys(IconsPackage);
return iconsKeyList.map((key) => {
const Icon = IconsPackage[key];
IconsPackage[key].displayName = key;
return <Icon {...args} key={key} />;
});
};
5 changes: 5 additions & 0 deletions packages/components/src/Logotype/Logotype.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { HTMLProps } from 'react';

export interface LogotypeProps extends HTMLProps<HTMLImageElement> {}

export default function Logotype(props: LogotypeProps): JSX.Element;
22 changes: 22 additions & 0 deletions packages/components/src/Logotype/Logotype.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions packages/components/src/Logotype/Logotype.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import Logotype from './Logotype';

export default {
title: 'Design System/Atoms/Logo',
component: Logotype,
};

const Template = (args) => <Logotype {...args} />;

export const Logo = Template.bind({});

Logo.args = {
width: 220,
};
2 changes: 2 additions & 0 deletions packages/components/src/Logotype/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default } from './Logotype';
export * from './Logotype';
1 change: 1 addition & 0 deletions packages/components/src/Logotype/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './Logotype';
4 changes: 2 additions & 2 deletions packages/components/src/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export { default as ButtonExample } from './ButtonExample';
export * from './ButtonExample';
export { default as Logotype } from './Logotype';
export * from './Logotype';
2 changes: 1 addition & 1 deletion packages/components/src/index.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { default as ButtonExample } from './ButtonExample';
export { default as Logotype } from './Logotype';
60 changes: 60 additions & 0 deletions packages/icons/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"name": "@master-c8/icons",
"version": "0.1.0",
"private": false,
"description": "Platzi Master C8 Theme",
"main": "./dist/index",
"author": "Platzi Master C8",
"license": "MIT",
"keywords": [
"platzi master",
"c8",
"react",
"gethired-commons",
"platzi",
"theme",
"icons"
],
"contributors": [
{
"name": "Kevin Cruz",
"github": "https://github.com/kevfarid"
},
{
"name": "Yadu Lopez",
"github": "https://github.com/yadurani"
}
],
"repository": {
"type": "git",
"url": "git+https://github.com/Platzi-Master-C8/gethired-commons.git",
"directory": "packages/theme"
},
"bugs": {
"url": "https://github.com/Platzi-Master-C8/gethired-commons/issues"
},
"homepage": "https://github.com/Platzi-Master-C8/gethired-commons",
"scripts": {
"build": "NODE_ENV=production && rm -rf ./dist && mkdir dist && npx babel --config-file ../../babel.config src/ --out-dir dist --copy-files --ignore '**/*.spec.js' --ignore '**/*.stories.@(js|jsx|ts|tsx)' --no-copy-ignored"
},
"peerDependencies": {
"@types/react": ">=16.8.0",
"react": ">=16.8.0"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
}
},
"dependencies": {
"prop-types": "15.7.2",
"@mui/material": "^5.2.1"
},
"publishConfig": {
"access": "public"
},
"engines": {
"node": ">=12.0.0"
}
}

Loading

0 comments on commit 1372cb0

Please sign in to comment.