Skip to content
This repository has been archived by the owner on Nov 3, 2022. It is now read-only.

Commit

Permalink
Merge pull request #29 from comfortdelgro/release/v0.9.05-beta
Browse files Browse the repository at this point in the history
release/v0.9.05-beta
  • Loading branch information
hanetooth authored Aug 10, 2022
2 parents 9881808 + 2e25c85 commit baa45fd
Show file tree
Hide file tree
Showing 47 changed files with 707 additions and 327 deletions.
5 changes: 3 additions & 2 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# `yarn publish` should ignore `src`
# Since all required files in src will be copied to dist by bable
src
public
build
# other npm unrealted directories
.storybook
.github
.git
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@comfortdelgro/design-system",
"description": "Comfort Delgro's design system",
"version": "0.9.0-beta",
"version": "0.9.05-beta",
"dependencies": {
"baseui": "^11.0.2",
"react": "^17.0.2",
Expand Down
Binary file removed public/favicon.ico
Binary file not shown.
43 changes: 0 additions & 43 deletions public/index.html

This file was deleted.

Binary file removed public/logo192.png
Binary file not shown.
Binary file removed public/logo512.png
Binary file not shown.
25 changes: 0 additions & 25 deletions public/manifest.json

This file was deleted.

3 changes: 0 additions & 3 deletions public/robots.txt

This file was deleted.

52 changes: 52 additions & 0 deletions src/components/Accordions/Accordions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import * as React from "react";
import PropTypes from "prop-types";
import {
Accordion as BuiAccordion,
Panel as BuiPanel,
} from "baseui/accordion";
import override from "./override";

export const Accordion = React.forwardRef(({ overrides, children, ...restProps }, ref) => {
const localOverrides = override(overrides);
return (
<BuiAccordion
ref={ref}
overrides={localOverrides}
{...restProps}
>
{ children }
</BuiAccordion>
);
});

export const Panel = React.forwardRef((props, ref) => {
return (
<BuiPanel ref={ref} {...props}/>
)
});

Accordion.propTypes = {
overrides: PropTypes.shape({
Content: PropTypes.object,
ContentAnimationContainer: PropTypes.object,
Header: PropTypes.object,
PanelContainer: PropTypes.object,
Root: PropTypes.object,
ToggleIcon: PropTypes.object,
}),
children: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.element),
PropTypes.element
]).isRequired,
};

Accordion.defaultProps = {
overrides: {
Content: {},
ContentAnimationContainer: {},
Header: {},
PanelContainer: {},
Root: {},
ToggleIcon: {},
},
};
18 changes: 18 additions & 0 deletions src/components/Accordions/Accordions.stories.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { useState } from 'react';
import { Meta, Story, Preview } from "@storybook/addon-docs";
import { action } from "@storybook/addon-actions";
import { Accordion, Panel } from "./Accordions";

<Meta title="Contents" component={Accordion} />

<Canvas withToolbar>
<Story
name="Accordions">
<Accordion
onChange={action("onChange")}>
<Panel title="Panel 1">Content 1</Panel>
<Panel title="Panel 2">Content 2</Panel>
<Panel title="Panel 3">Content 3</Panel>
</Accordion>
</Story>
</Canvas>
5 changes: 5 additions & 0 deletions src/components/Accordions/Accordions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { AccordionProps, PanelProps } from "baseui/accordion";
import * as React from 'react';

export declare const Accordion: React.FC<AccordionProps>;
export declare const Panel: React.FC<PanelProps>;
1 change: 1 addition & 0 deletions src/components/Accordions/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./Accordions.js";
1 change: 1 addition & 0 deletions src/components/Accordions/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./Accordions.js";
60 changes: 60 additions & 0 deletions src/components/Accordions/override.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { resolveComponent, resolveProps, resolveStyle } from "../override";
import { margin, padding } from "../../utils/helpers/style";

const override = ({
Content,
ContentAnimationContainer,
Header,
PanelContainer,
Root,
ToggleIcon
}) => ({
Root: {
style: (props) => ({
...resolveStyle(Root, props),
}),
props: resolveProps({}, Root),
...resolveComponent(Root),
},
Content: {
style: ({ $theme, $disabled, $error, ...restProps }) => ({
...resolveStyle(Content, { $theme, $disabled, $error, ...restProps }),
}),
props: resolveProps({}, Content),
...resolveComponent(Content),
},
ContentAnimationContainer: {
style: ({ $theme, $disabled, $error, ...restProps }) => ({
...resolveStyle(ContentAnimationContainer, { $theme, $disabled, $error, ...restProps }),
}),
props: resolveProps({}, ContentAnimationContainer),
...resolveComponent(ContentAnimationContainer),
},
Header: {
style: ({ $theme, $disabled, $error, ...restProps }) => ({
...$theme.typography.accordionHeader,
...padding("24px 25px 24px 25px"),
...resolveStyle(Header, { $theme, $disabled, $error, ...restProps }),
}),
props: resolveProps({}, Header),
...resolveComponent(Header),
},
PanelContainer: {
style: ({ $theme, $disabled, $error, ...restProps }) => ({
...resolveStyle(PanelContainer, { $theme, $disabled, $error, ...restProps }),
}),
props: resolveProps({}, PanelContainer),
...resolveComponent(PanelContainer),
},
ToggleIcon: {
style: ({ $theme, $disabled, $error, ...restProps }) => ({
...resolveStyle(ToggleIcon, { $theme, $disabled, $error, ...restProps }),
}),
props: resolveProps({}, ToggleIcon),
// component: (props) => {
// console.debug("ToggleIconPorps", props);
// }
...resolveComponent(ToggleIcon),
},
});
export default override;
43 changes: 43 additions & 0 deletions src/components/Avatars/Avatar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import * as React from "react";
import PropTypes from "prop-types";
import {
Avatar as BuiAvatar,
} from "baseui/avatar";
import override from "./override";

export const Avatar = React.forwardRef(({ overrides, size, ...restProps }, ref) => {
const localOverrides = override(overrides);
return (
<BuiAvatar
ref={ref}
overrides={localOverrides}
size={size}
{...restProps}
/>
);
});

export const SIZES = {
lg: "40px",
md: "32px",
sm: "24px",
xs: "16px",
}

Avatar.propTypes = {
overrides: PropTypes.shape({
Root: PropTypes.object,
Avatar: PropTypes.object,
Initials: PropTypes.object,
}),
size: PropTypes.string
};

Avatar.defaultProps = {
overrides: {
Root: {},
Avatar: {},
Initials: {},
},
size: SIZES.md,
};
31 changes: 31 additions & 0 deletions src/components/Avatars/Avatar.stories.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Meta, Story, Preview } from "@storybook/addon-docs";
import { action } from "@storybook/addon-actions";
import { Avatar, SIZES } from "./Avatar";
import { FlexGrid, FlexGridItem } from "baseui/flex-grid";

<Meta title="Components" component={Avatar} />

export const Template = (props) => (
<React.Fragment>
<FlexGrid
flexGridColumnCount={4}>
{Object.keys(SIZES).map((key, index) => (
<FlexGridItem
key={`sb-avatar-wic-${key}-${index}`}>
<Avatar
name="Jane Doe"
size={SIZES[key]}
src={`https://avatars.dicebear.com/api/human/${index}.svg?width=285&mood=happy`}
/>
</FlexGridItem>
))}
</FlexGrid>
</React.Fragment>
)

<Canvas withToolbar>
<Story
name="Avatars">
{Template.bind({})}
</Story>
</Canvas>
10 changes: 10 additions & 0 deletions src/components/Avatars/Avatar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { AvatarProps } from "baseui/avatar";
import * as React from 'react';

export declare const Avatar: React.FC<AvatarProps>;
export declare const SIZES: {
lg: string,
md: string,
sm: string
xs: string,
};
1 change: 1 addition & 0 deletions src/components/Avatars/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./Avatar.js";
1 change: 1 addition & 0 deletions src/components/Avatars/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./Avatar.js";
47 changes: 47 additions & 0 deletions src/components/Avatars/override.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { resolveComponent, resolveProps, resolveStyle } from "../override";
import { SIZES } from "./Avatar";
import { borderRadius, padding } from "../../utils/helpers/style";

function resovleAvatarTypoScale(size, theme) {
console.debug('resovleAvatarTypoScale', size);
switch (size) {
case SIZES.lg:
return theme.typography.avatarLg;
case SIZES.sm:
return theme.typography.avatarSm;
case SIZES.xs:
return theme.typography.avatarXs;
default:
return theme.typography.avatarMd;
}
};

const override = ({
Avatar,
Root,
Initials,
}) => ({
Avatar: {
style: (props) => ({
...resolveStyle(Avatar, props),
}),
props: resolveProps({}, Avatar),
...resolveComponent(Avatar),
},
Root: {
style: (props) => ({
...resolveStyle(Root, props),
}),
props: resolveProps({}, Root),
...resolveComponent(Root),
},
Initials: {
style: (props) => ({
// TODO:: fix baseweb err and apply typo
...resolveStyle(Initials, props),
}),
props: resolveProps({}, Initials),
...resolveComponent(Initials),
},
});
export default override;
3 changes: 1 addition & 2 deletions src/components/Breadcrumbs/Breadcrumbs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ export namespace Breadcrumbs {
}
export { overrides_1 as overrides };
}
}
//# sourceMappingURL=Breadcrumbs.d.ts.map
}
Loading

0 comments on commit baa45fd

Please sign in to comment.