Skip to content

Commit 60d0543

Browse files
committed
feat: add Island component with toast functionality and Storybook example
1 parent bfa64c0 commit 60d0543

5 files changed

Lines changed: 408 additions & 16 deletions

File tree

package-lock.json

Lines changed: 113 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@
142142
"access": "public"
143143
},
144144
"dependencies": {
145-
"@radix-ui/react-progress": "^1.1.8"
145+
"@radix-ui/react-progress": "^1.1.8",
146+
"motion": "^12.40.0",
147+
"zustand": "^5.0.13"
146148
}
147149
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import {Meta} from "@storybook/react-vite";
2+
import React from "react";
3+
import {Island, useIsland} from "./Island";
4+
import {ButtonGroup} from "../button-group/ButtonGroup";
5+
import {Button} from "../button/Button";
6+
import {Text} from "../text/Text";
7+
import {IconCircleCheck, IconCircleX, IconFileSpark} from "@tabler/icons-react";
8+
import {Card} from "../card/Card";
9+
import {Flex} from "../flex/Flex";
10+
import {FullScreen} from "../fullscreen/FullScreen";
11+
import {Progress} from "../progress/Progress";
12+
13+
export default {
14+
title: "Island",
15+
parameters: {
16+
visualTest: {
17+
selector: 'body'
18+
},
19+
layout: "fullscreen"
20+
},
21+
} as Meta
22+
23+
export const IslandExample = () => {
24+
25+
const island = useIsland()
26+
27+
return <FullScreen>
28+
<Flex pos={"fixed"} top={"1rem"} left={"0"} w={"100%"} justify={"center"} style={{zIndex: 9999}}>
29+
<Island>
30+
<ButtonGroup color={"primary"} bg={"transparent"} style={{boxShadow: "none"}}>
31+
<Button paddingSize={"xxs"} variant={"none"}>
32+
<Text>Home</Text>
33+
</Button>
34+
<Button paddingSize={"xxs"} variant={"none"}>
35+
<Text>Organizations</Text>
36+
</Button>
37+
<Button paddingSize={"xxs"} variant={"none"}>
38+
<Text>Projects</Text>
39+
</Button>
40+
</ButtonGroup>
41+
</Island>
42+
</Flex>
43+
<Card color={"secondary"} mt={5}>
44+
<Button onClick={() => {
45+
island.addToast({
46+
icon: <IconFileSpark color={"#70ffb2"} size={16}/>,
47+
message: <Text c={"#70ffb2"}>workflow limit almost reached</Text>,
48+
largeContent: <Flex w={"410px"} style={{flexDirection: "column", gap: "0.7rem"}}>
49+
<Progress value={30} predictionValue={120} max={100} color={"linear-gradient(to right, #29BF12 0%, #D90429 100%)"}/>
50+
<Text>
51+
You used 50% of your available workflow executions and will used 75% until its reseted.
52+
</Text>
53+
<Flex align={"center"} style={{gap: "0.7rem"}}>
54+
<Button w={"100%"}>
55+
Add new license
56+
</Button>
57+
<Button w={"100%"}>
58+
Buy new license
59+
</Button>
60+
</Flex>
61+
</Flex>
62+
})
63+
}}>
64+
Info
65+
</Button>
66+
<Button onClick={() => {
67+
island.addToast({
68+
icon: <IconCircleCheck color={"#29BF12"} size={16}/>,
69+
message: <Text c={"#29BF12"}>Added license</Text>,
70+
})
71+
}}>
72+
Success
73+
</Button>
74+
<Button onClick={() => {
75+
island.addToast({
76+
icon: <IconCircleX color={"#D90429"} size={16}/>,
77+
message: <Text c={"#D90429"}>Internal error</Text>,
78+
})
79+
}}>
80+
Error
81+
</Button>
82+
</Card>
83+
</FullScreen>
84+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
@use "../../styles/helpers";
2+
@use "../../styles/box";
3+
@use "../../styles/variables";
4+
5+
.island {
6+
@include box.box(variables.$primary, variables.$white, variables.$primary);
7+
@include helpers.borderRadius();
8+
cursor: pointer;
9+
10+
* {
11+
box-sizing: border-box;
12+
}
13+
14+
&__icon {
15+
--path-offset: 300%;
16+
display: inline-flex;
17+
18+
padding-left: variables.$xs;
19+
20+
& svg path {
21+
stroke-dasharray: 300%;
22+
stroke-dashoffset: inherit;
23+
}
24+
}
25+
26+
&__message {
27+
padding-right: variables.$xs;
28+
}
29+
30+
&__content {
31+
padding: variables.$xs;
32+
}
33+
}

0 commit comments

Comments
 (0)