Skip to content

Commit 6f612eb

Browse files
committed
more component fixes
1 parent af5c475 commit 6f612eb

File tree

19 files changed

+40
-26
lines changed

19 files changed

+40
-26
lines changed
File renamed without changes.
+24-12
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,44 @@
1-
import { css, cx } from "$/styles/css";
1+
import { css, cva, cx } from "$/styles/css";
22
import { hstack, vstack } from "$/styles/patterns";
3+
import { RecipeVariantProps } from "$/styles/types";
34
import { PropsWithChildren } from "react";
45

56
interface Props {
67
title?: string;
78
}
8-
9-
function Component({ title, children }: PropsWithChildren<Props>) {
9+
function Component({ title, variant, children }: PropsWithChildren<Props> & RecipeVariantProps<typeof cn.root>) {
1010
return (
11-
<aside className={cx(cn.root)}>
12-
{title && <span className={cx(cn.heading)}>{title}</span>}
11+
<aside className={cx(cn.root({ variant }))}>
12+
<span className={cx(cn.heading)}>{title ?? variant?.toUpperCase()}</span>
1313
<small className={cx(cn.content)}>{children}</small>
1414
</aside>
1515
);
1616
}
1717

1818
const cn = {
19-
root: vstack({
20-
gap: 1,
21-
alignItems: "start",
22-
width: "full",
23-
padding: 4,
24-
backgroundColor: "container",
19+
root: cva({
20+
base: vstack.raw({
21+
gap: 1,
22+
alignItems: "start",
23+
width: "full",
24+
padding: 4,
25+
}),
26+
variants: {
27+
variant: {
28+
info: {
29+
backgroundColor: "container",
30+
},
31+
},
32+
},
2533
}),
2634
heading: hstack({
2735
fontWeight: "bold",
2836
}),
29-
content: css({}),
37+
content: css({
38+
"& :last-child": {
39+
marginY: 0,
40+
},
41+
}),
3042
};
3143

3244
export { Component };
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as stub } from "./stub";
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import { Callout } from "$/components/ui/molecules";
22
import { metadata } from "$/constants";
3+
import { ComponentPropsWithoutRef } from "react";
34

4-
function Component() {
5-
return (
6-
<Callout title="INFO">
5+
export default {
6+
variant: "info",
7+
children: (
8+
<p>
79
This is a stub section.
810
<br />
911
If you have suggestions for content you'd like to see included here, join the{" "}
1012
<a href={metadata.repository.concat("/discussions")} target="_blank">
1113
discussions
1214
</a>{" "}
1315
and leave your thoughts!
14-
</Callout>
15-
);
16-
}
17-
18-
export { Component };
16+
</p>
17+
),
18+
} as ComponentPropsWithoutRef<typeof Callout>;

src/components/ui/templates/index.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
export { Component as DatasetActions } from "./actions/dataset";
22
export { Component as LevelActions } from "./actions/level";
33
export { Component as RowActions } from "./actions/row";
4-
export { Component as Stub } from "./callout/stub";
54
export { Component as LevelCharts } from "./charts/level";
65
export { Component as PieCharts } from "./charts/pie";
76
export { Component as TimeCharts } from "./charts/time";
8-
export { Component as ArchiveDataForm } from "./form/archive";
9-
export { Component as ManualDatasetForm } from "./form/dataset";
10-
export { Component as ManualDataForm } from "./form/level";
7+
export { Component as ArchiveDataForm } from "./forms/archive";
8+
export { Component as ManualDatasetForm } from "./forms/dataset";
9+
export { Component as ManualDataForm } from "./forms/level";
1110

11+
export * as callouts from "./callouts";
1212
export * as tables from "./tables";

src/pages/[key]/level/[sid]/[bid]/index.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Badge } from "$/components/ui/atoms";
2+
import { Callout } from "$/components/ui/molecules";
23
import { Content } from "$/components/ui/organisms";
3-
import { LevelActions, Stub } from "$/components/ui/templates";
4+
import { LevelActions, callouts } from "$/components/ui/templates";
45
import { resolveLevelIndex } from "$/helpers";
56
import { useDataset, useTitle } from "$/hooks";
67
import { useParams } from "$/router";
@@ -59,7 +60,7 @@ export default function Page() {
5960
}
6061
return (
6162
<Content title={<Title />} layout={"level"}>
62-
{data ? <Stub /> : "This level is not available."}
63+
{data ? <Callout {...callouts.stub} /> : "This level is not available."}
6364
</Content>
6465
);
6566
}

0 commit comments

Comments
 (0)