-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpage.tsx
141 lines (133 loc) · 5.03 KB
/
page.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
"use client";
import {
Box,
Container,
Card,
Group,
Stack,
Text,
Title,
TextInput,
} from "@mantine/core";
import { CodeHighlightTabs } from "@mantine/code-highlight";
import { useState } from "react";
import prettier from "prettier/standalone";
import { ColorSchemeToggle } from "./_components/themeToggle";
const highlight1 = `<Paper p={{ base: "md", md: "lg" }} shadow="md">
<Text>This is a pure Mantine component</Text>
</Paper>`;
const highlight2 = `<Paper
classNames={{
root: "group bg-mtn-primary-light-color text-light-grape-filled px-mtn-md py-mtn-lg my-mtn-xl rounded-lg text-white italic shadow-sm hover:shadow-mtn-lg cursor-pointer transition duration-150 ease-in-out"
}}
>
<Text
classNames={{
root: "group-hover:underline",
}}
>
This component is a mixin with tailwind class
</Text>
</Paper>`;
const highlight3 = `<Paper
p={{ base: "md", md: "lg" }}
shadow="md"
>
<p className="text-light-text text-sm font-semibold">
This a Mantine Input component with floating label by Tailwind
</p>
<TextInput
labelProps={{ "data-floating": floating }}
onFocus={() => setFocused(true)}
onBlur={() => setFocused(false)}
value={value}
onChange={(event) => setValue(event.currentTarget.value)}
classNames={{
root: "relative mt-[12px]",
input: "border-b-1",
label:
"absolute z-10 pointer-events-none top-[7px] left-[12px] text-red-800 text-sm transition-all duration-100 ease-in data-[floating=true]:translate-y-[-20px] text-base data-[floating=true]:text-xs data-[floating=true]:text-mtn-primary-filled-hover bg-red-300 data-[floating=true]:bg-white dark:data-[floating=true]:bg-mtn-dark-6 px-0 data-[floating=true]:px-1 data-[floating=true]:left-[8px]",
}}
label="Floating label"
/>
</Paper>`;
export default function Home() {
const [value, setValue] = useState("");
const [focused, setFocused] = useState(false);
const floating = focused || value.length > 0 || undefined;
return (
<Box mih={"100vh"} miw={"100vw"} className="bg-gray-100 dark:bg-mtn-dark-8">
<Container size="xs">
<Stack py={"xl"}>
<Group justify={"space-between"}>
<Title order={2}>Hello to Mantine V7 with Tailwind!</Title>
<ColorSchemeToggle />
</Group>
<Stack mt={"lg"}>
<Card p={{ base: "md", md: "lg" }} shadow="md">
<Text>This is a pure Mantine component</Text>
</Card>
<Card
classNames={{
root: "group bg-mtn-primary-light-color text-light-grape-filled px-mtn-md py-mtn-lg my-mtn-xl rounded-lg text-white italic shadow-sm hover:shadow-mtn-lg cursor-pointer transition duration-150 ease-in-out",
}}
>
<Text
classNames={{
root: "group-hover:underline",
}}
>
This component is a mixin with tailwind class
</Text>
</Card>
<Card p={{ base: "md", md: "lg" }} shadow="md">
<Text className="text-light-text text-sm font-semibold">
This a Mantine Input component with floating label by Tailwind
</Text>
<TextInput
labelProps={{ "data-floating": floating }}
onFocus={() => setFocused(true)}
onBlur={() => setFocused(false)}
value={value}
onChange={(event) => setValue(event.currentTarget.value)}
classNames={{
root: "relative mt-[12px]",
input: "border-b-1",
label:
"absolute z-10 pointer-events-none top-[7px] left-[12px] text-light-placeholder text-sm transition-all duration-100 ease-in data-[floating=true]:translate-y-[-20px] text-base data-[floating=true]:text-xs data-[floating=true]:text-mtn-primary-filled-hover bg-transparent dark:data-[floating=true]:bg-mtn-dark-6 data-[floating=true]:bg-white px-0 data-[floating=true]:px-1 data-[floating=true]:left-[8px]",
}}
label="Floating label"
/>
</Card>
{/* Code CodeHighlight */}
<Card p={{ base: "md", md: "lg" }} shadow="md">
<CodeHighlightTabs
withExpandButton
defaultExpanded={false}
expandCodeLabel="Show full code"
collapseCodeLabel="Show less"
code={[
{
language: "tsx",
code: highlight1,
fileName: "pure-mantine",
},
{
language: "tsx",
code: highlight2,
fileName: "mixin-tailwind",
},
{
language: "tsx",
code: highlight3,
fileName: "input-floating",
},
]}
/>
</Card>
</Stack>
</Stack>
</Container>
</Box>
);
}