@edu-tosel/design 1.0.10 → 1.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,5 +6,5 @@ export default function CanvasBoard({ children, options }) {
6
6
  const sizes = "h-full ";
7
7
  const paddings = "pb-36 xl:pb-0 px-2 xs:px-4 xl:pl-8 xl:pr-2 pt-2 xs:pt-4 xl:pt-8";
8
8
  const styles = "overflow-y-scroll ";
9
- return (_jsx(Board, { options: options, children: _jsx("div", { className: cn(layouts, sizes, paddings, styles), children: children }) }));
9
+ return (_jsx(Board, { options: { ...options, isRounded: true }, children: _jsx("div", { className: cn(layouts, sizes, paddings, styles), children: children }) }));
10
10
  }
@@ -13,7 +13,7 @@ export default function ManageBoard({ header, data, widgets, }) {
13
13
  const sizes = `h-full ${dataField ? "xl:h-135" : "xl:h-158"}`;
14
14
  const paddings = "pb-60 xl:pb-0 px-2 xs:px-4 xl:px-8";
15
15
  const styles = "overflow-y-scroll";
16
- return (_jsxs(Board, { widgets: widgets, children: [_jsx(BoardHeader, { ...header }), dataField && _jsx(BoardDataField, { dataField: dataField }), _jsx("div", { className: cn(positions, sizes, paddings, styles), children: _jsx(Exception, { exceptions: widgets?.exceptions, children: dataSets.map(({ title: deckTitle, items, renderItem }) => deckTitle ? (_jsx("div", { className: "pt-4", children: _jsx(Deck, { titles: { title: deckTitle ?? "" }, children: items?.map((item) => renderItem(item)) }) }, deckTitle)) : (items
16
+ return (_jsxs(Board, { widgets: widgets, options: { isRounded: true }, children: [_jsx(BoardHeader, { ...header }), dataField && _jsx(BoardDataField, { dataField: dataField }), _jsx("div", { className: cn(positions, sizes, paddings, styles), children: _jsx(Exception, { exceptions: widgets?.exceptions, children: dataSets.map(({ title: deckTitle, items, renderItem }) => deckTitle ? (_jsx("div", { className: "pt-4", children: _jsx(Deck, { titles: { title: deckTitle ?? "" }, children: items?.map((item) => renderItem(item)) }) }, deckTitle)) : (items
17
17
  ?.slice()
18
18
  .sort((a, b) => {
19
19
  if (orderBy) {
@@ -4,7 +4,7 @@ import { Board } from "../widget/Board";
4
4
  export default function PaperBoard({ children, debug }) {
5
5
  const container = {
6
6
  displays: "flex flex-col items-center gap-7.5",
7
- paddings: "px-4 pt-3",
7
+ paddings: "px-4 pt-5 pb-16",
8
8
  };
9
- return (_jsx(Board, { options: { width: "lg", height: "full" }, debug: debug, children: _jsx("div", { className: cn(container), children: children }) }));
9
+ return (_jsx(Board, { options: { width: "lg", height: "full", isRounded: false }, debug: debug, children: _jsx("div", { className: cn(container), children: children }) }));
10
10
  }
@@ -25,7 +25,7 @@ const heightSize = {
25
25
  export function Board({ children, widgets, options, debug }) {
26
26
  const { events } = useWidgetStore();
27
27
  const { components, tabs } = widgets ?? {};
28
- const { width, height } = options ?? {};
28
+ const { width, height, isRounded } = options ?? {};
29
29
  const container = {
30
30
  positions: "relative",
31
31
  width: widthSize[width ?? "full"],
@@ -34,7 +34,8 @@ export function Board({ children, widgets, options, debug }) {
34
34
  const body = {
35
35
  positions: "relative z-10 ",
36
36
  sizes: `w-full ${heightSize[height ?? "lg"]} overflow-hidden `,
37
- styles: "xl:rounded-xl bg-white",
37
+ styles: "bg-white",
38
+ rounded: `rounded-none ${isRounded ? "xl:rounded-xl" : ""}`,
38
39
  };
39
40
  return (_jsxs("div", { className: cn(container), children: [_jsxs("div", { className: cn(body), children: [children, components?.map(([flag, Component]) => {
40
41
  if (typeof flag === "boolean")
@@ -1,2 +1,2 @@
1
1
  import { ChartCardProps } from "../../interface/Card";
2
- export default function ChartCard({ data, xAxis, yAxis, lines, bars, areas, options, }: ChartCardProps): import("react/jsx-runtime").JSX.Element;
2
+ export default function ChartCard({ data, xAxis, yAxis, lines, bars, areas, options, average, }: ChartCardProps): import("react/jsx-runtime").JSX.Element;
@@ -1,11 +1,12 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Area, Bar, ComposedChart, Line, ResponsiveContainer, Tooltip, XAxis, YAxis, } from "recharts";
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Area, Bar, ComposedChart, Legend, Line, ReferenceLine, ResponsiveContainer, Tooltip, XAxis, YAxis, } from "recharts";
3
3
  import { Card } from "../widget/Card";
4
- export default function ChartCard({ data, xAxis, yAxis, lines, bars, areas, options, }) {
4
+ export default function ChartCard({ data, xAxis, yAxis, lines, bars, areas, options, average, }) {
5
5
  const { width, height } = options ?? {};
6
- return (_jsx(Card, { options: {
6
+ return (_jsxs(Card, { options: {
7
+ classNames: "pt-4 pr-4",
7
8
  width: width ?? "xl",
8
9
  height: height ?? "lg",
9
10
  text: { size: "xs" },
10
- }, children: _jsx(ResponsiveContainer, { width: "100%", height: "100%", children: _jsxs(ComposedChart, { data: data, children: [_jsx(XAxis, { dataKey: xAxis }), _jsx(YAxis, { dataKey: yAxis }), _jsx(Tooltip, {}), lines?.map((line) => (_jsx(Line, { ...line }, line.dataKey))), bars?.map((bar) => (_jsx(Bar, { ...bar }, bar.dataKey))), areas?.map((area) => (_jsx(Area, { ...area }, area.dataKey)))] }) }) }));
11
+ }, children: [_jsx(ResponsiveContainer, { width: "100%", height: "100%", children: _jsxs(ComposedChart, { data: data, children: [_jsx(XAxis, { dataKey: xAxis }), _jsx(YAxis, { dataKey: yAxis }), _jsx(Tooltip, {}), _jsx(Legend, {}), lines?.map((line) => (_jsx(Line, { ...line }, line.dataKey))), bars?.map((bar) => (_jsx(Bar, { ...bar }, bar.dataKey))), areas?.map((area) => (_jsx(Area, { ...area }, area.dataKey))), average && (_jsx(_Fragment, { children: _jsx(ReferenceLine, { x: average.x, stroke: "#ff0000" }) }))] }) }), average && (_jsxs("div", { className: "absolute top-0 left-0 w-full h-full flex justify-center items-center text-3xl text-gray-300 font-bold", children: ["\uD3C9\uADE0: ", average?.score, "\uC810"] }))] }));
11
12
  }
@@ -1,9 +1,13 @@
1
1
  import { Titles } from "../../interface";
2
2
  export default function ReportCard({ titles, type, dataSets, dataField, }: {
3
3
  titles: Titles;
4
- type: "table" | "chart";
4
+ type: "text" | "table" | "chart";
5
5
  dataSets: {
6
6
  items: Record<string, string | number>[];
7
+ average?: {
8
+ x: string;
9
+ score: number;
10
+ };
7
11
  };
8
12
  dataField: {
9
13
  fields: Record<string, string>;
@@ -15,6 +19,15 @@ export default function ReportCard({ titles, type, dataSets, dataField, }: {
15
19
  dataKey: string;
16
20
  stroke: string;
17
21
  }[];
22
+ bars?: {
23
+ name: string;
24
+ dataKey: string;
25
+ fill: string;
26
+ }[];
27
+ areas?: {
28
+ dataKey: string;
29
+ fill: string;
30
+ }[];
18
31
  sizes?: Record<string, string>;
19
32
  };
20
33
  }): import("react/jsx-runtime").JSX.Element;
@@ -5,7 +5,7 @@ import ChartCard from "./ChartCard";
5
5
  import TableCard from "./TableCard";
6
6
  export default function ReportCard({ titles, type, dataSets, dataField, }) {
7
7
  const { title, subtitle } = titles;
8
- const { axis, fields, lines, sizes } = dataField;
8
+ const { axis, fields, lines, bars, areas, sizes } = dataField;
9
9
  const container = {
10
10
  displays: "flex flex-col gap-4",
11
11
  };
@@ -14,10 +14,10 @@ export default function ReportCard({ titles, type, dataSets, dataField, }) {
14
14
  title: "text-lg font-bold",
15
15
  subtitle: "text-sm",
16
16
  };
17
- return (_jsxs("div", { className: cn(container), children: [_jsxs("div", { className: cn(titleBox.container), children: [_jsx("div", { className: cn(titleBox.title), children: title }), _jsx(LineBreaks, { className: cn(titleBox.subtitle), texts: subtitle })] }), type === "table" && sizes ? (_jsx(TableCard, { sizes: sizes, fields: fields, data: dataSets.items, options: {
17
+ return (_jsxs("div", { className: cn(container), children: [_jsxs("div", { className: cn(titleBox.container), children: [_jsx("div", { className: cn(titleBox.title), children: title }), _jsx(LineBreaks, { className: cn(titleBox.subtitle), texts: subtitle })] }), type === "text" ? (_jsx("div", { children: "text" })) : type === "table" && sizes ? (_jsx(TableCard, { sizes: sizes, fields: fields, data: dataSets.items, options: {
18
18
  width: "full",
19
19
  height: "auto",
20
- } })) : axis && type === "chart" ? (_jsx(ChartCard, { data: dataSets.items, xAxis: axis.x, yAxis: axis.y, lines: lines, options: {
20
+ } })) : axis && type === "chart" ? (_jsx(ChartCard, { data: dataSets.items, xAxis: axis.x, yAxis: axis.y, lines: lines, bars: bars, areas: areas, average: dataSets.average, options: {
21
21
  width: "full",
22
22
  } })) : null] }));
23
23
  }
@@ -13,5 +13,5 @@ export default function TableCard({ data, fields, sizes, options, }) {
13
13
  `flex h-11 items-center font-bold pl-4`,
14
14
  `bg-${bgColor ?? "gray-300"} text-${textColor ?? "black"}`,
15
15
  ].join(" ");
16
- return (_jsx(Card, { options: { width: width ?? "lg", height: height ?? "lg", overflow }, children: _jsxs("div", { className: cn(container), children: [_jsx("div", { className: fieldsClassNames, children: keys.map((key) => (_jsx("div", { className: `w-${sizes[key]}`, children: fields[key] }, key))) }), data.map((row, index) => (_jsx("div", { className: "flex items-center pl-4 h-11 ", children: keys.map((key) => (_jsx("div", { className: `truncate w-${sizes[key] ?? "auto"}`, children: row[key] }, key))) }, index)))] }) }));
16
+ return (_jsx(Card, { options: { width: width ?? "lg", height: height ?? "lg", overflow }, children: _jsxs("div", { className: cn(container), children: [_jsx("div", { className: fieldsClassNames, children: keys.map((key) => (_jsx("div", { className: `w-${sizes[key]}/100`, children: fields[key] }, key))) }), data.map((row, index) => (_jsx("div", { className: "flex items-center pl-4 h-11 ", children: keys.map((key) => (_jsx("div", { className: `truncate w-${sizes[key] ?? "auto"}`, children: row[key] }, key))) }, index)))] }) }));
17
17
  }
@@ -21,7 +21,7 @@ const heightSize = {
21
21
  auto: "h-auto min-h-80",
22
22
  };
23
23
  export function Card({ children, options, debug }) {
24
- const { boundary, rounded, height, width, text, background, onClick, overflow, } = options ?? {};
24
+ const { classNames, boundary, rounded, height, width, text, background, onClick, overflow, } = options ?? {};
25
25
  const { size: textSize, color: textColor } = text ?? {};
26
26
  const { color: bgColor } = background ?? {};
27
27
  const setBoundary = () => {
@@ -44,5 +44,5 @@ export function Card({ children, options, debug }) {
44
44
  styles: "duration-500 overflow-hidden",
45
45
  debug: debug && import.meta.env.MODE && `border-2 border-${debug}`,
46
46
  };
47
- return (_jsx("div", { onClick: onClick, className: cn(container), children: children }));
47
+ return (_jsx("div", { onClick: onClick, className: cn(container, `${classNames}`), children: children }));
48
48
  }
package/deck/Deck.js CHANGED
@@ -11,7 +11,8 @@ export function Deck({ children, titles, options, debug, }) {
11
11
  `border-2 border-${debug}`,
12
12
  };
13
13
  const body = {
14
- displays: `flex flex-col sm:flex-${flex ?? "row"} gap-y-${gapY ?? 5}`,
14
+ displays: `flex flex-col flex-wrap gap-y-${gapY ?? 5}`,
15
+ flex: flex === "col" ? "sm:flex-col" : "sm:flex-row",
15
16
  justify: `justify-${justify ?? "start"}`,
16
17
  gapX: `${`gap-x-${gapX ?? 7.5}`}`,
17
18
  sizes: "sm:w-full ",
@@ -1,4 +1,5 @@
1
1
  export { default as Exception } from "./template/Exception";
2
2
  export { default as LoadingSpinner } from "./widget/LoadingSpinner";
3
3
  export { default as LoadingJumper } from "./widget/LoadingJumper";
4
+ export { default as LoadingWorm } from "./widget/LoadingWorm";
4
5
  export { default as NoData } from "./widget/NoData";
@@ -1,4 +1,5 @@
1
1
  export { default as Exception } from "./template/Exception";
2
2
  export { default as LoadingSpinner } from "./widget/LoadingSpinner";
3
3
  export { default as LoadingJumper } from "./widget/LoadingJumper";
4
+ export { default as LoadingWorm } from "./widget/LoadingWorm";
4
5
  export { default as NoData } from "./widget/NoData";
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  // NOTE: This is Prototype code and should be replaced with a proper loading spinner
3
3
  export default function LoadingSpinner() {
4
- return (_jsx("div", { className: "w-full h-full flex items-center justify-center", children: _jsx("div", { className: "w-30 h-30", children: _jsxs("svg", { "aria-hidden": "true", className: "inline w-4 h-4 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600", viewBox: "0 0 100 101", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [_jsx("path", { d: "M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z", fill: "currentColor" }), _jsx("path", { d: "M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z", fill: "currentFill" })] }) }) }));
4
+ return (_jsx("div", { className: "w-full h-full flex items-center justify-center", children: _jsx("div", { className: "w-30 h-30", children: _jsxs("svg", { "aria-hidden": "true", className: "inline w-20 h-20 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600", viewBox: "0 0 100 101", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [_jsx("path", { d: "M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z", fill: "currentColor" }), _jsx("path", { d: "M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z", fill: "currentFill" })] }) }) }));
5
5
  }
@@ -3,21 +3,21 @@ import { cn, gradient, useEase } from "../../util";
3
3
  export default function LoadingWorm() {
4
4
  const numbers = [-2, -1, 0, 1, 2];
5
5
  const ease = useEase(1000, 500);
6
- return (_jsx("div", { className: "w-full h-full flex justify-center items-center", children: _jsx("div", { className: "relative w-25 h-22 ", children: numbers.map((number) => (_jsx(SubComponent, { index: number, ease: ease }, number))) }) }));
6
+ return (_jsx("div", { className: "w-full h-full flex justify-center items-center", children: _jsx("div", { className: "relative w-25 h-20 ", children: numbers.map((number) => (_jsx(SubComponent, { index: number, ease: ease }, number))) }) }));
7
7
  }
8
8
  function SubComponent({ index, ease, }) {
9
9
  const [flag, timer] = ease;
10
10
  const positions = [
11
11
  `absolute`,
12
12
  index < 0
13
- ? `-left-${flag ? Math.abs(index) * 4 : 0}`
14
- : `left-${flag ? Math.abs(index) * 4 : 0}`,
13
+ ? `-right-${flag ? Math.abs(index) * 4 : 0}`
14
+ : `right-${flag ? Math.abs(index) * 4 : 0}`,
15
15
  index < 0
16
16
  ? `-top-${flag ? Math.abs(index) * 4 : 0}`
17
17
  : `top-${flag ? Math.abs(index) * 4 : 0}`,
18
18
  `z-${50 - index}`,
19
19
  ].join(" ");
20
- const sizes = "w-25 h-22";
21
- const styles = `duration-${timer} rounded-lg bg-${gradient.lab}`;
20
+ const sizes = "w-25 h-20";
21
+ const styles = `duration-${timer} rounded-lg bg-${gradient.lab} opacity-40`;
22
22
  return (_jsxs("div", { className: cn(positions, sizes, styles), children: [_jsxs("div", { children: ["Index is ", index] }), _jsxs("div", { className: "text-xs", children: [timer, "ms \uB3D9\uC548 ", flag.toString()] })] }));
23
23
  }
@@ -4,6 +4,7 @@ interface OptionsProps {
4
4
  width?: Size;
5
5
  height?: Size;
6
6
  color?: string;
7
+ isRounded?: boolean;
7
8
  }
8
9
  interface WidgetsProps {
9
10
  exceptions?: [boolean, React.ReactNode][];
@@ -14,6 +14,7 @@ import { ImageSize, Size } from "./Property";
14
14
  export interface CardProps {
15
15
  children: React.ReactNode;
16
16
  options?: {
17
+ classNames?: string;
17
18
  boundary?: "shadow" | "border" | "none";
18
19
  rounded?: string;
19
20
  height?: Size;
@@ -46,6 +47,10 @@ export interface ChartCardProps extends Omit<CardProps, "children"> {
46
47
  dataKey: string;
47
48
  fill: string;
48
49
  }[];
50
+ average?: {
51
+ x: string;
52
+ score: number;
53
+ };
49
54
  }
50
55
  export interface TableCardProps extends Omit<CardProps, "children"> {
51
56
  data: Record<string, string | number>[];
@@ -0,0 +1,4 @@
1
+ export default function Header({ groupName, examName, }: {
2
+ groupName: string;
3
+ examName: string;
4
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cn } from "../../util";
3
+ export default function Header({ groupName, examName, }) {
4
+ const container = {
5
+ positions: "relative z-20",
6
+ displays: "flex flex-col items-center ",
7
+ sizes: "w-full max-w-280",
8
+ styles: "py-8 bg-white shadow-md",
9
+ };
10
+ return (_jsxs("div", { className: cn(container), children: [_jsxs("div", { className: "flex justify-between w-full items-center pr-2", children: [_jsx("img", { src: "/images/logos/itc.png", alt: "itc", width: 100 }), _jsx("div", { className: "flex items-center", children: _jsx("div", { className: "text-5xl font-bold", children: examName }) }), _jsx("img", { src: "/images/logos/badge-tosel-lab.png", alt: "tosel-lab", width: 80 })] }), _jsxs("div", { className: "", children: ["\uC9C0\uC815\uAD50\uC721\uAE30\uAD00: ", groupName] })] }));
11
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edu-tosel/design",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "description": "UI components for International TOSEL Committee",
5
5
  "keywords": [
6
6
  "jsx",
@@ -14,6 +14,7 @@
14
14
  "type": "module",
15
15
  "scripts": {},
16
16
  "dependencies": {
17
+ "@edu-tosel/design": "^1.0.11",
17
18
  "react": "^18.2.0",
18
19
  "react-dom": "^18.2.0",
19
20
  "react-lottie-player": "^1.5.6",
package/version.txt CHANGED
@@ -1 +1 @@
1
- 1.0.10
1
+ 1.0.12