Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
e5ee00c
feat: Add datagrid story
ChrisBaidoo Jun 20, 2022
1feb943
fix: display data in DataGrid
ChrisBaidoo Jun 22, 2022
5dd70e7
feat: add dialog story
ChrisBaidoo Jun 22, 2022
d41763c
Merge branch 'moreStories' of https://github.com/gliff-ai/style into …
ChrisBaidoo Jun 22, 2022
19266b0
Merge branch 'main' of https://github.com/gliff-ai/style into moreSto…
ChrisBaidoo Jun 23, 2022
42431b2
feat: add Popover, Dialog and Loading Spinner stories
ChrisBaidoo Jun 23, 2022
3af815b
feat: add logo and loading spinner stories
ChrisBaidoo Jun 24, 2022
5a3dfd1
feat: add button story WIP
ChrisBaidoo Jun 27, 2022
ef2fd30
feat: wrap stories in theme decorator
ChrisBaidoo Jun 28, 2022
268db18
feat: add primary, secondary and outline button stories
ChrisBaidoo Jun 28, 2022
9eda4bf
feat: add buttons to Dialog
ChrisBaidoo Jun 28, 2022
36646c0
feat: remove some controls from UI in storybook.
ChrisBaidoo Jun 28, 2022
2f7fb18
feat: merge in remote branch
ChrisBaidoo Jun 28, 2022
057967b
add Chip Story WIP
ChrisBaidoo Jun 30, 2022
94c6109
feat add Textfield story
ChrisBaidoo Jul 1, 2022
f594b2c
feat: add iconbutton within the textfield component
ChrisBaidoo Jul 6, 2022
f41391f
feat: conditionally render the icon
ChrisBaidoo Jul 6, 2022
8566543
feat: style input label
ChrisBaidoo Jul 7, 2022
287afe3
feat: popper story WIP
ChrisBaidoo Jul 8, 2022
abdf1ff
feat: add autocomplete WIP
ChrisBaidoo Jul 11, 2022
496b666
feat: add tooltip story
ChrisBaidoo Jul 12, 2022
4061031
feat: run prettier on all files
ChrisBaidoo Jul 13, 2022
97a2499
feat: remove unneeded prop
ChrisBaidoo Jul 13, 2022
2223449
Merge branch 'main' of https://github.com/gliff-ai/style into additio…
ChrisBaidoo Jul 13, 2022
6c47ed0
feat: add status icon to tooltip
ChrisBaidoo Jul 13, 2022
296a179
feat: remove makestyles
ChrisBaidoo Jul 13, 2022
da261db
feat: apply CSS to directly to Button component
ChrisBaidoo Jul 14, 2022
7078bcf
feat: style Autocomplete
ChrisBaidoo Jul 15, 2022
319677a
feat remove some of the controls in Textfield story
ChrisBaidoo Jul 18, 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
21,245 changes: 6,669 additions & 14,576 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"scripts": {
"build": "npx vite build -c vite.config.lib.ts && tsc --emitDeclarationOnly --outDir dist && tsc-alias -p tsconfig.json && npm run build:patch",
"watch": "npx vite build -c vite.config.lib.ts --watch",
"format": "npx --no-install prettier --write src/*.ts*",
"format": "npx --no-install prettier --write src/**/*.ts*",
"prettier": "npx --no-install prettier -c src/*.ts*",
"lint": "tsc --noEmit && npm run lint:ts && npm run prettier",
"lint:ts": "npx --no-install eslint src/*.ts*",
Expand Down Expand Up @@ -91,4 +91,4 @@
"dependencies": {
"react-inlinesvg": "^2.3.0"
}
}
}
14 changes: 14 additions & 0 deletions src/components/Autocomplete/Autocomplete.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable react/jsx-props-no-spreading */
import { Autocomplete } from "./Autocomplete";

export default {
title: "Autocomplete",
component: Autocomplete,
};

// A wrapper function from Storybook that allows you to pass in props to your component. We use this for showing controls
const Template = (args: any) => <Autocomplete {...args} />;

export const AutocompleteSingle = Template.bind({});
23 changes: 23 additions & 0 deletions src/components/Autocomplete/Autocomplete.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ReactElement } from "react";

import { Autocomplete as MaterialAutocomplete, TextField } from "@mui/material";

export function Autocomplete(): JSX.Element {
return (
<MaterialAutocomplete
options={top100Films}
getOptionLabel={(option: any) => option.title}
renderInput={(params) => (
<TextField {...params} label="Combo box" variant="outlined" fullWidth />
)}
/>
);
}

const top100Films = [
{ title: "The Shawshank Redemption", year: 1994 },
{ title: "The Godfather", year: 1972 },
{ title: "The Godfather: Part II", year: 1974 },
{ title: "The Dark Knight", year: 2008 },
{ title: "12 Angry Men", year: 1957 },
];
10 changes: 10 additions & 0 deletions src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ interface Props extends ButtonProps {
disabled?: boolean;
}

const button = {
borderRadius: "6px",
fontWeight: 400,
fontSize: "15px",
letterSpacing: 0,
padding: "7px 20px",
boxShadow: "none",
};

export function Button({
text,
onClick,
Expand All @@ -23,6 +32,7 @@ export function Button({
disableElevation
// eslint-disable-next-line react/jsx-props-no-spreading
{...rest}
sx={{ ...button }}
>
{text}
</MuiButton>
Expand Down
10 changes: 2 additions & 8 deletions src/components/Card/Card.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import { ReactElement } from "react";

import {
Card as MaterialCard,
Paper,
Typography,
styled,

} from "@mui/material";
import { Card as MaterialCard, Paper, Typography, styled } from "@mui/material";
import SVG from "react-inlinesvg";
import { theme } from "../../theme";
import { icons } from "../../icons";
Expand Down Expand Up @@ -56,7 +50,7 @@ export function Card(props: Props): JSX.Element {
"button:last-child": {
marginRight: "-8px",
},
border: `1px solid ${props.warningDialog ? "#9F6DEA":"#02E098"}`,
border: `1px solid ${props.warningDialog ? "#9F6DEA" : "#02E098"}`,
}}
>
{props.warningDialog && (
Expand Down
19 changes: 19 additions & 0 deletions src/components/Chip/Chip.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable react/jsx-props-no-spreading */
import { Chip } from "./Chip";

export default {
title: "Chip",
component: Chip,
};

// A wrapper function from Storybook that allows you to pass in props to your component. We use this for showing controls
const Template = (args: any) => <Chip {...args} />;

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

Primary.args = {
label: "Chip",
closeButton: false,
};
54 changes: 54 additions & 0 deletions src/components/Chip/Chip.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { MouseEvent, ReactElement } from "react";
import { Chip as MuiChip, Avatar } from "@mui/material";
import type { ChipProps } from "@mui/material/Chip";
import SVG from "react-inlinesvg";
import { icons } from "../../icons";
import { theme } from "../../theme";

interface Props extends ChipProps {
key: string;
onClick?: (event: MouseEvent) => void;
disabled?: boolean;
closeButton?: boolean;
// data-testid?: string;
label: string;
}

export function Chip({
key,
onClick,
disabled,
label,
closeButton,
...rest
}: Props): ReactElement {
return (
<MuiChip
key={key}
variant="outlined"
avatar={
closeButton ? (
<Avatar
variant="circular"
sx={{ cursor: "pointer" }}
onClick={onClick}
data-testid="todo"
>
<SVG
width="15px"
src={icons.removeLabel}
fill={theme.palette.text.secondary}
/>
</Avatar>
) : null
}
label={label}
/>
);
}

Chip.defaultProps = {
onClick: null,
disabled: false,
closeButton: true,
};
67 changes: 67 additions & 0 deletions src/components/Dialog/Dialog.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable react/jsx-props-no-spreading */
import { IconButton } from "../IconButton/IconButton";
import { Dialog } from "./Dialog";

const imgSrc = (src: string, type = "svg"): string =>
new URL(`/src/assets/${src}.${type}`, import.meta.url).href;

export default {
title: "Dialog",
component: Dialog,
argTypes: {
// remove some property from the controls UI
// TODO possibly move this into a separate file
TriggerButton: {
table: {
disable: true,
},
},
warningDialog: {
table: {
disable: true,
},
},
close: {
table: {
disable: true,
},
},
afterClose: {
table: {
disable: true,
},
},
},
};

// A wrapper function from Storybook that allows you to pass in props to your component. We use this for showing controls
const Template = (args: any) => (
<Dialog
{...args}
TriggerButton={
<IconButton
tooltip={{
name: "Open Dialog",
}}
icon={imgSrc("icon")}
size="medium"
/>
}
/>
);

export const StandardDialog = Template.bind({});
export const ConfirmationDialog = Template.bind({});
StandardDialog.args = {
title: "Standard Dialog",
children: "Content",
buttons: true,
};
ConfirmationDialog.args = {
title: "Confirmation Dialog",
children: "Content",
warningDialog: "true",
buttons: true,
};
99 changes: 99 additions & 0 deletions src/components/Dialog/Dialog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import { ReactElement, useState, cloneElement, useEffect } from "react";
import { Box, Dialog as MaterialDialog, Typography } from "@mui/material";
import { Card } from "../Card/Card";
import { Button } from "../Button/Button";

interface Props {
children?: ReactElement | null;
TriggerButton: JSX.Element;
title: string;
warningDialog?: boolean;
close?: boolean;
afterClose?: () => void;
buttons?: boolean;
}

export function Dialog({
children,
title,
TriggerButton,
close,
warningDialog,
afterClose,
buttons,
}: Props): ReactElement | null {
const [open, setOpen] = useState<boolean>(false);

const handleClick = (): void => {
setOpen(true);
};

const handleClose = (): void => {
setOpen(false);
// Reset defaults when Dialog is closed
if (afterClose) {
afterClose();
}
};

// externally close the Dialog
useEffect(() => {
if (close) {
setOpen(false);
}
}, [close]);

const dialogContent = (
<>
<Card
title={title}
handleClose={handleClose}
closeButton
warningDialog={warningDialog}
>
<>
<Typography>{children}</Typography>

{buttons && (
<Box
sx={{
display: "flex",
justifyContent: "space-between",
marginTop: "60px",
}}
>
<Button text="Button" color="secondary" variant="outlined" />
<Button
text="Button"
color={warningDialog ? "secondary" : "primary"}
/>
</Box>
)}
</>
</Card>
</>
);

return (
<>
{cloneElement(TriggerButton, {
onClick: () => {
handleClick();
const { onClick } = TriggerButton.props as { onClick?: () => void };
if (onClick) onClick();
},
})}
<MaterialDialog open={open} onClose={handleClose}>
{dialogContent}
</MaterialDialog>
</>
);
}

Dialog.defaultProps = {
children: null,
close: null,
afterClose: null,
warningDialog: null,
buttons: false,
};
Empty file.
44 changes: 44 additions & 0 deletions src/components/Popper/Popper.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import {
Popper as MaterialPopper,
ClickAwayListener,
PopperPlacementType,
PopperProps,
} from "@mui/material";

interface Props extends PopperProps {
open: boolean;
anchorEl: HTMLButtonElement | null;
el: JSX.Element;
handleClickAway?: () => void;
offset?: [number, number];
popperPlacement?: PopperPlacementType;
}

export function Popper(props: Props): JSX.Element {
return (
<ClickAwayListener onClickAway={props.handleClickAway}>
<MaterialPopper
open={props.open}
anchorEl={props.anchorEl}
style={{ display: "flex" }}
placement={props.popperPlacement}
modifiers={[
{
name: "offset",
options: {
offset: props.offset,
},
},
]}
>
{props.el}
</MaterialPopper>
</ClickAwayListener>
);
}

Popper.defaultProps = {
handleClickAway: null,
popperPlacement: "right",
offset: [10, 10],
};
Loading