Skip to content

Commit

Permalink
Merge branch 'master' of github.com:npocccties/ChibiCHiLO into feat-i…
Browse files Browse the repository at this point in the history
…mport-books
  • Loading branch information
hATrayflood committed Jul 1, 2021
2 parents f4e5a41 + cde8fd6 commit 613ab62
Show file tree
Hide file tree
Showing 82 changed files with 1,364 additions and 937 deletions.
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ MIT License

Copyright (c) 2020-2021 NPO CCC-TIES
Copyright (c) 2020-2021 National Institute of Informatics
Copyright (c) 2020-2021 Osaka University

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
11 changes: 11 additions & 0 deletions components/atoms/DescriptionList.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export default { title: "atoms/DescriptionList" };

import DescriptionList from "./DescriptionList";

const value = [...Array(10)].fill({ key: "key", value: "value" });

export const Default = () => <DescriptionList value={value} />;

export const Inline = () => <DescriptionList inline value={value} />;

export const Nowrap = () => <DescriptionList nowrap value={value} />;
84 changes: 84 additions & 0 deletions components/atoms/DescriptionList.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import clsx from "clsx";
import { makeStyles, createStyles } from "@material-ui/core/styles";
import type { Theme } from "@material-ui/core/styles";
import grey from "@material-ui/core/colors/grey";

type StyleProps = {
color: string;
fontSize: string;
};

const useStyles = makeStyles((theme: Theme) =>
createStyles({
root: {
margin: 0,
color: ({ color }: StyleProps) => color,
fontSize: ({ fontSize }: StyleProps) => fontSize,
lineHeight: 1.25,
"& > $item:not(:last-child)": {
marginBottom: theme.spacing(0.5),
},
"&$inline > $item, &$nowrap > $item": {
display: "inline-flex",
},
"&$inline > $item:not(:last-child), &$nowrap > $item:not(:last-child)": {
marginRight: theme.spacing(1.25),
},
"&$nowrap": {
overflow: "hidden",
textOverflow: "ellipsis",
whiteSpace: "nowrap",
},
},
item: {
display: "flex",
"& > dt::after": {
content: "':'",
marginRight: theme.spacing(0.25),
},
"& > dd": {
margin: 0,
},
},
inline: {},
nowrap: {},
})
);

type Props = {
className?: string;
color?: string;
fontSize?: string;
inline?: boolean;
nowrap?: boolean;
value: Array<{ key: string; value: string }>;
};

export default function DescriptionList({
className,
color = grey[700],
fontSize = "0.75rem",
inline = false,
nowrap = false,
value,
}: Props) {
const classes = useStyles({ color, fontSize });

return (
<dl
className={clsx(
className,
classes.root,
{ [classes.inline]: inline },
{ [classes.nowrap]: nowrap }
)}
>
{value.map(({ key, value }, index) => (
<div key={index} className={classes.item}>
<dt>{key}</dt>
<dd>{value}</dd>
</div>
))}
</dl>
);
}
7 changes: 7 additions & 0 deletions components/atoms/EditButton.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default { title: "atoms/EditButton" };

import EditButton from "./EditButton";

export const Book = () => <EditButton variant="book" />;

export const Topic = () => <EditButton variant="topic" />;
24 changes: 24 additions & 0 deletions components/atoms/EditButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import EditOutlinedIcon from "@material-ui/icons/EditOutlined";
import IconButton from "$atoms/IconButton";

type Props = Omit<Parameters<typeof IconButton>[0], "tooltipProps"> & {
variant: "book" | "topic";
};

const label = {
book: "ブック",
topic: "トピック",
} as const;

export default function EditButton({ variant, ...other }: Props) {
return (
<IconButton
tooltipProps={{ title: `${label[variant]}を編集` }}
color="primary"
size="small"
{...other}
>
<EditOutlinedIcon />
</IconButton>
);
}
12 changes: 12 additions & 0 deletions components/atoms/IconButton.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export default { title: "atoms/IconButton" };

import CloseIcon from "@material-ui/icons/Close";
import IconButton from "./IconButton";

export const Default = () => {
return (
<IconButton tooltipProps={{ title: "閉じる" }}>
<CloseIcon />
</IconButton>
);
};
15 changes: 15 additions & 0 deletions components/atoms/IconButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import MuiIconButton from "@material-ui/core/IconButton";
import Tooltip from "@material-ui/core/Tooltip";

type Props = Parameters<typeof MuiIconButton>[0] & {
tooltipProps: Omit<Parameters<typeof Tooltip>[0], "children">;
};

export default function IconButton(props: Props) {
const { tooltipProps, ...others } = props;
return (
<Tooltip {...tooltipProps}>
<MuiIconButton {...others} />
</Tooltip>
);
}
23 changes: 0 additions & 23 deletions components/atoms/Item.stories.tsx

This file was deleted.

30 changes: 0 additions & 30 deletions components/atoms/Item.tsx

This file was deleted.

25 changes: 25 additions & 0 deletions components/atoms/Markdown.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
export default { title: "atoms/Markdown" };

import Markdown from "./Markdown";
import outdent from "outdent";

export const Default = () => (
<Markdown>
{outdent`
# h1
## h2
### h3
#### h4
###### h5
###### h6
paragraph
paragraph
`}
</Markdown>
);
24 changes: 24 additions & 0 deletions components/atoms/Markdown.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import ReactMarkdown from "react-markdown";
import gfm from "remark-gfm";
import breaks from "remark-breaks";
import Link from "@material-ui/core/Link";
import type { LinkProps } from "@material-ui/core/Link";

function MarkdownLink<Element extends React.ElementType>(
props: LinkProps<Element>
) {
return <Link target="_blank" rel="noreferrer" {...props} />;
}

type Props = Pick<Parameters<typeof ReactMarkdown>[0], "children">;

export default function Markdown({ children }: Props) {
const components = {
a: MarkdownLink,
};
return (
<ReactMarkdown remarkPlugins={[gfm, breaks]} components={components}>
{children}
</ReactMarkdown>
);
}
7 changes: 7 additions & 0 deletions components/atoms/PreviewButton.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default { title: "atoms/PreviewButton" };

import PreviewButton from "./PreviewButton";

export const Book = () => <PreviewButton variant="book" />;

export const Topic = () => <PreviewButton variant="topic" />;
24 changes: 24 additions & 0 deletions components/atoms/PreviewButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import VisibilityOutlinedIcon from "@material-ui/icons/VisibilityOutlined";
import IconButton from "$atoms/IconButton";

type Props = Omit<Parameters<typeof IconButton>[0], "tooltipProps"> & {
variant: "book" | "topic";
};

const label = {
book: "ブック",
topic: "トピック",
} as const;

export default function PreviewButton({ variant, ...other }: Props) {
return (
<IconButton
tooltipProps={{ title: `${label[variant]}をプレビュー` }}
size="small"
color="primary"
{...other}
>
<VisibilityOutlinedIcon />
</IconButton>
);
}
7 changes: 7 additions & 0 deletions components/atoms/RemoveButton.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default { title: "atoms/RemoveButton" };

import RemoveButton from "./RemoveButton";

export const Topic = () => <RemoveButton variant="topic" />;

export const Section = () => <RemoveButton variant="section" />;
24 changes: 24 additions & 0 deletions components/atoms/RemoveButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import RemoveIcon from "@material-ui/icons/Remove";
import IconButton from "$atoms/IconButton";

type Props = Omit<Parameters<typeof IconButton>[0], "tooltipProps"> & {
variant: "topic" | "section";
};

const label = {
topic: "トピック",
section: "セクション",
} as const;

export default function RemoveButton({ variant, ...other }: Props) {
return (
<IconButton
color="primary"
size="small"
{...other}
tooltipProps={{ title: `この${label[variant]}を取り除く` }}
>
<RemoveIcon />
</IconButton>
);
}
4 changes: 0 additions & 4 deletions components/atoms/TreeItem.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import TreeView from "@material-ui/lab/TreeView";
import ExpandMoreIcon from "@material-ui/icons/ExpandMore";
import ChevronRightIcon from "@material-ui/icons/ChevronRight";
import IconButton from "@material-ui/core/IconButton";
import InfoOutlinedIcon from "@material-ui/icons/InfoOutlined";
import EditOutlinedIcon from "@material-ui/icons/EditOutlined";

export const Default = () => (
Expand All @@ -18,9 +17,6 @@ export const Default = () => (
label={
<>
コンピュータ・サイエンス
<IconButton size="small">
<InfoOutlinedIcon />
</IconButton>
<IconButton size="small" color="primary">
<EditOutlinedIcon />
</IconButton>
Expand Down
Loading

0 comments on commit 613ab62

Please sign in to comment.