@zvoove/unity-ui 2.19.1
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.
- package/README.md +175 -0
- package/dist/theme.css +586 -0
- package/dist/unity-ui.cjs.js +1 -0
- package/dist/unity-ui.css +1 -0
- package/dist/unity-ui.d.ts +3705 -0
- package/dist/unity-ui.es.js +2018 -0
- package/package.json +116 -0
package/README.md
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
<br />
|
|
4
|
+
|
|
5
|
+
<picture>
|
|
6
|
+
<source media="(prefers-color-scheme: dark)" srcset="./public/logo-unity-ui-white.svg">
|
|
7
|
+
<img alt="UnityUI by zvoove" src="./public/logo-unity-ui.svg" width="600px">
|
|
8
|
+
</picture>
|
|
9
|
+
|
|
10
|
+
<br /><br />
|
|
11
|
+
|
|
12
|
+
[UnityUI](dub.sh/unity-ui) is a React implementation of [zvoove's](https://zvoove.de/) Design System. All React implementations can/should be built using this package.
|
|
13
|
+
|
|
14
|
+
<br />
|
|
15
|
+
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
# Getting Started
|
|
19
|
+
|
|
20
|
+
To get started with the Unity UI project, follow these steps:
|
|
21
|
+
|
|
22
|
+
## Adding UnityUI to your project
|
|
23
|
+
|
|
24
|
+
### npm registry (recommended)
|
|
25
|
+
|
|
26
|
+
The `unity-ui` is available as a public package on [npmjs](https://www.npmjs.com/package/@zvoove/unity-ui). You can install it directly:
|
|
27
|
+
|
|
28
|
+
```shell
|
|
29
|
+
npm i @zvoove/unity-ui
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### GitHub Packages registry (legacy)
|
|
33
|
+
|
|
34
|
+
> **Note:** We are transitioning to the public npm registry (`@zvoove/unity-ui`). The GitHub Packages registry (`@zvoove-org/unity-ui`) will be discontinued in the future. We recommend migrating to the npm registry as soon as possible.
|
|
35
|
+
|
|
36
|
+
The `unity-ui` is also available on [our private package registry on GitHub](https://github.com/orgs/zvoove-org/packages?repo_name=unity-ui). To install from GitHub Packages, you'll need to [setup a personal access token](https://github.com/settings/tokens) with the `read:packages` permission.
|
|
37
|
+
|
|
38
|
+
Configure the token for `npm`: `npm config set //npm.pkg.github.com/:_authToken $TOKEN`.
|
|
39
|
+
|
|
40
|
+
Then create a `.npmrc` file in the root of your project:
|
|
41
|
+
|
|
42
|
+
```shell
|
|
43
|
+
@zvoove-org:registry=https://npm.pkg.github.com/zvoove-org
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Then install:
|
|
47
|
+
|
|
48
|
+
```shell
|
|
49
|
+
npm i @zvoove-org/unity-ui
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
`@zvoove/unity-ui` (or `@zvoove-org/unity-ui`) has required peer dependencies for `react` and `react-dom`. If your project doesn't have them already, make sure you have installed using at least **v18**
|
|
55
|
+
|
|
56
|
+
## Styles
|
|
57
|
+
|
|
58
|
+
The `unity-ui` uses [tailwindcss](https://tailwindcss.com/docs/installation/framework-guides) for styling, so you have to include the compiled `unity-ui.css` file in your project. This file contains all the compiled css to make the components to look like they should.
|
|
59
|
+
|
|
60
|
+
In case you want to install `tailwindcss` in your project and have access to the UnityUI theme, you can install [tailwindcss](https://tailwindcss.com/docs/installation/framework-guides) in your project and import the `theme.css` file in your `index.css` to have access to the pre-defined design tokens of the Design system.
|
|
61
|
+
|
|
62
|
+
```css
|
|
63
|
+
/* index.css or main.css etc... */
|
|
64
|
+
|
|
65
|
+
@import '@zvoove-org/unity-ui/theme.css';
|
|
66
|
+
@import '@zvoove-org/unity-ui/unity-ui.css';
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
The `theme.css` file contains all the design tokens used in the project, so you can use them in your styles.
|
|
70
|
+
|
|
71
|
+
After that you can use the components in your project and you can also use the design tokens in your styles. (Check our [Design Tokens](https://main--67c03f013fea08bb2f926e5f.chromatic.com/?path=/docs/design-tokens--docs) section for more information)
|
|
72
|
+
|
|
73
|
+
```jsx
|
|
74
|
+
import { Button } from '@zvoove-org/unity-ui';
|
|
75
|
+
|
|
76
|
+
const App = () => {
|
|
77
|
+
return (
|
|
78
|
+
<div className="bg-primary text-on-primary">
|
|
79
|
+
<Button>Click me</Button>
|
|
80
|
+
</div>
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export default App;
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Dark Mode
|
|
88
|
+
|
|
89
|
+
The `unity-ui` has a dark mode that can be enabled by adding the `dark` data attribute to the root element of your application.
|
|
90
|
+
|
|
91
|
+
```jsx
|
|
92
|
+
import { Button } from '@zvoove-org/unity-ui';
|
|
93
|
+
|
|
94
|
+
const App = () => {
|
|
95
|
+
return (
|
|
96
|
+
<div data-theme="dark">
|
|
97
|
+
<Button>Click me</Button>
|
|
98
|
+
</div>
|
|
99
|
+
);
|
|
100
|
+
};
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
if you are using it in a NextJS project, you can set it up in the top level `layout.tsx` file.
|
|
104
|
+
|
|
105
|
+
```jsx
|
|
106
|
+
const Layout = ({ children }) => {
|
|
107
|
+
return <div data-theme="dark">{children}</div>;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
export default Layout;
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
you can also force a specific component to be in dark mode by adding the `dark` data attribute to the component.
|
|
114
|
+
|
|
115
|
+
```jsx
|
|
116
|
+
import { Button } from '@zvoove-org/unity-ui';
|
|
117
|
+
|
|
118
|
+
<Button data-theme="dark">Click me</Button>;
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Fonts
|
|
122
|
+
|
|
123
|
+
Our project uses the `Source Sans` font family available at [google fonts](https://fonts.google.com/specimen/Source+Sans+3), you can include it in your project by adding the following lines to your `<head>` tag:
|
|
124
|
+
|
|
125
|
+
```html
|
|
126
|
+
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
127
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
128
|
+
<link
|
|
129
|
+
href="https://fonts.googleapis.com/css2?family=Source+Sans+3:ital,wght@0,200..900;1,200..900&display=swap"
|
|
130
|
+
rel="stylesheet"
|
|
131
|
+
/>
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Fonts in NextJS
|
|
135
|
+
|
|
136
|
+
For `NextJS` you can load the fonts using `next/font` like this:
|
|
137
|
+
|
|
138
|
+
```jsx
|
|
139
|
+
import './globals.css';
|
|
140
|
+
import { Source_Sans_3 } from 'next/font/google';
|
|
141
|
+
|
|
142
|
+
const sourceSans3 = Source_Sans_3({
|
|
143
|
+
subsets: ['latin'],
|
|
144
|
+
variable: '--font-source-sans-3',
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
export default async function RootLayout({
|
|
148
|
+
children,
|
|
149
|
+
}: Readonly<{
|
|
150
|
+
children: React.ReactNode;
|
|
151
|
+
}>) {
|
|
152
|
+
return (
|
|
153
|
+
<html lang="de-DE" className={sourceSans3.variable}>
|
|
154
|
+
<body data-theme="light">{children}</body>
|
|
155
|
+
</html>
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
And then you update your `globals.css` with:
|
|
161
|
+
|
|
162
|
+
```css
|
|
163
|
+
@import '@zvoove-org/unity-ui/theme.css';
|
|
164
|
+
@import '@zvoove-org/unity-ui/unity-ui.css';
|
|
165
|
+
|
|
166
|
+
@layer base {
|
|
167
|
+
html {
|
|
168
|
+
font-family: var(--font-source-sans-3);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## Installing (Development)
|
|
174
|
+
|
|
175
|
+
To learn how to develop and contribute with this project, please check our [`CONTRIBUTING`](https://main--67c03f013fea08bb2f926e5f.chromatic.com/?path=/docs/contributing--docs) session on storybook.
|