@public-ui/sample-react 1.7.0-rc.5 → 1.7.0-rc.7
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/package.json +9 -12
- package/prettier.config.js +0 -1
- package/public/index.html +2 -2
- package/src/App.tsx +35 -163
- package/src/components/Sidebar.tsx +81 -0
- package/src/{samples → components}/split-button/routes.ts +1 -1
- package/src/shares/routes.ts +41 -41
- package/src/shares/store.ts +2 -2
- package/src/style.scss +8 -59
- package/unocss.config.ts +2 -2
- /package/src/{samples → components}/abbr/basic.html +0 -0
- /package/src/{samples → components}/abbr/basic.tsx +0 -0
- /package/src/{samples → components}/abbr/routes.ts +0 -0
- /package/src/{samples → components}/accordion/basic.tsx +0 -0
- /package/src/{samples → components}/accordion/header.tsx +0 -0
- /package/src/{samples → components}/accordion/headlines.tsx +0 -0
- /package/src/{samples → components}/accordion/list.tsx +0 -0
- /package/src/{samples → components}/accordion/routes.ts +0 -0
- /package/src/{samples → components}/alert/basic.tsx +0 -0
- /package/src/{samples → components}/alert/card-msg.tsx +0 -0
- /package/src/{samples → components}/alert/html.tsx +0 -0
- /package/src/{samples → components}/alert/routes.ts +0 -0
- /package/src/{samples → components}/avatar/basic.tsx +0 -0
- /package/src/{samples → components}/avatar/routes.ts +0 -0
- /package/src/{samples → components}/badge/basic.tsx +0 -0
- /package/src/{samples → components}/badge/button.tsx +0 -0
- /package/src/{samples → components}/badge/routes.ts +0 -0
- /package/src/{samples → components}/breadcrumb/basic.tsx +0 -0
- /package/src/{samples → components}/breadcrumb/routes.ts +0 -0
- /package/src/{samples → components}/button/basic.tsx +0 -0
- /package/src/{samples → components}/button/hide-label.tsx +0 -0
- /package/src/{samples → components}/button/icons.tsx +0 -0
- /package/src/{samples → components}/button/routes.ts +0 -0
- /package/src/{samples → components}/button/width.tsx +0 -0
- /package/src/{samples → components}/button-group/basic.tsx +0 -0
- /package/src/{samples → components}/button-group/routes.ts +0 -0
- /package/src/{samples → components}/button-link/basic.tsx +0 -0
- /package/src/{samples → components}/button-link/icons.tsx +0 -0
- /package/src/{samples → components}/button-link/image.tsx +0 -0
- /package/src/{samples → components}/button-link/routes.ts +0 -0
- /package/src/{samples → components}/button-link/target.tsx +0 -0
- /package/src/{samples → components}/card/basic.tsx +0 -0
- /package/src/{samples → components}/card/confirm.tsx +0 -0
- /package/src/{samples → components}/card/flex.tsx +0 -0
- /package/src/{samples → components}/card/routes.ts +0 -0
- /package/src/{samples → components}/card/selection.tsx +0 -0
- /package/src/{samples → components}/details/basic.tsx +0 -0
- /package/src/{samples → components}/details/routes.ts +0 -0
- /package/src/{samples → components}/form/routes.ts +0 -0
- /package/src/{samples → components}/handout/basic.tsx +0 -0
- /package/src/{samples → components}/handout/routes.ts +0 -0
- /package/src/{samples → components}/heading/badged.tsx +0 -0
- /package/src/{samples → components}/heading/basic.tsx +0 -0
- /package/src/{samples → components}/heading/paragraph.tsx +0 -0
- /package/src/{samples → components}/heading/routes.ts +0 -0
- /package/src/{samples → components}/icon/basic.tsx +0 -0
- /package/src/{samples → components}/icon/routes.ts +0 -0
- /package/src/{samples → components}/indented-text/basic.tsx +0 -0
- /package/src/{samples → components}/indented-text/routes.ts +0 -0
- /package/src/{samples → components}/input-checkbox/basic.tsx +0 -0
- /package/src/{samples → components}/input-checkbox/routes.ts +0 -0
- /package/src/{samples → components}/input-color/basic.tsx +0 -0
- /package/src/{samples → components}/input-color/routes.ts +0 -0
- /package/src/{samples → components}/input-date/basic.tsx +0 -0
- /package/src/{samples → components}/input-date/routes.ts +0 -0
- /package/src/{samples → components}/input-email/basic.tsx +0 -0
- /package/src/{samples → components}/input-email/routes.ts +0 -0
- /package/src/{samples → components}/input-file/basic.tsx +0 -0
- /package/src/{samples → components}/input-file/routes.ts +0 -0
- /package/src/{samples → components}/input-number/basic.tsx +0 -0
- /package/src/{samples → components}/input-number/routes.ts +0 -0
- /package/src/{samples → components}/input-password/basic.tsx +0 -0
- /package/src/{samples → components}/input-password/routes.ts +0 -0
- /package/src/{samples → components}/input-radio/basic.tsx +0 -0
- /package/src/{samples → components}/input-radio/horizontal.tsx +0 -0
- /package/src/{samples → components}/input-radio/routes.ts +0 -0
- /package/src/{samples → components}/input-radio/select.tsx +0 -0
- /package/src/{samples → components}/input-range/basic.tsx +0 -0
- /package/src/{samples → components}/input-range/routes.ts +0 -0
- /package/src/{samples → components}/input-text/basic.tsx +0 -0
- /package/src/{samples → components}/input-text/blur.tsx +0 -0
- /package/src/{samples → components}/input-text/focus.tsx +0 -0
- /package/src/{samples → components}/input-text/hidden-label.tsx +0 -0
- /package/src/{samples → components}/input-text/routes.ts +0 -0
- /package/src/{samples → components}/link/basic.tsx +0 -0
- /package/src/{samples → components}/link/icons.tsx +0 -0
- /package/src/{samples → components}/link/image.tsx +0 -0
- /package/src/{samples → components}/link/routes.ts +0 -0
- /package/src/{samples → components}/link/target.tsx +0 -0
- /package/src/{samples → components}/link-button/basic.tsx +0 -0
- /package/src/{samples → components}/link-button/routes.ts +0 -0
- /package/src/{samples → components}/link-group/routes.ts +0 -0
- /package/src/{samples → components}/nav/active.tsx +0 -0
- /package/src/{samples → components}/nav/aria-current.tsx +0 -0
- /package/src/{samples → components}/nav/basic.tsx +0 -0
- /package/src/{samples → components}/nav/horizontal.tsx +0 -0
- /package/src/{samples → components}/nav/routes.ts +0 -0
- /package/src/{samples → components}/pagination/basic.tsx +0 -0
- /package/src/{samples → components}/pagination/routes.ts +0 -0
- /package/src/{samples → components}/popover/basic.tsx +0 -0
- /package/src/{samples → components}/popover/routes.ts +0 -0
- /package/src/{samples → components}/progress/basic.tsx +0 -0
- /package/src/{samples → components}/progress/routes.ts +0 -0
- /package/src/{samples → components}/select/basic.tsx +0 -0
- /package/src/{samples → components}/select/routes.ts +0 -0
- /package/src/{samples → components}/skip-nav/basic.tsx +0 -0
- /package/src/{samples → components}/skip-nav/routes.ts +0 -0
- /package/src/{samples → components}/spin/basic.tsx +0 -0
- /package/src/{samples → components}/spin/custom.css +0 -0
- /package/src/{samples → components}/spin/custom.tsx +0 -0
- /package/src/{samples → components}/spin/cycle.tsx +0 -0
- /package/src/{samples → components}/spin/routes.ts +0 -0
- /package/src/{samples → components}/split-button/basic.tsx +0 -0
- /package/src/{samples → components}/table/badge-size.tsx +0 -0
- /package/src/{samples → components}/table/render-cell.tsx +0 -0
- /package/src/{samples → components}/table/routes.ts +0 -0
- /package/src/{samples → components}/table/sort-date.tsx +0 -0
- /package/src/{samples → components}/table/test-data.ts +0 -0
- /package/src/{samples → components}/textarea/adjust-height.tsx +0 -0
- /package/src/{samples → components}/textarea/basic.tsx +0 -0
- /package/src/{samples → components}/textarea/disabled.tsx +0 -0
- /package/src/{samples → components}/textarea/placeholder.tsx +0 -0
- /package/src/{samples → components}/textarea/readonly.tsx +0 -0
- /package/src/{samples → components}/textarea/resize.tsx +0 -0
- /package/src/{samples → components}/textarea/routes.ts +0 -0
- /package/src/{samples → components}/textarea/rows.tsx +0 -0
- /package/src/{samples → components}/toast/basic.tsx +0 -0
- /package/src/{samples → components}/toast/routes.ts +0 -0
- /package/src/{samples → components}/version/basic.tsx +0 -0
- /package/src/{samples → components}/version/context.tsx +0 -0
- /package/src/{samples → components}/version/routes.ts +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@public-ui/sample-react",
|
|
3
|
-
"version": "1.7.0-rc.
|
|
3
|
+
"version": "1.7.0-rc.7",
|
|
4
4
|
"description": "This app contains samples for the KoliBri/Public UI",
|
|
5
5
|
"license": "EUPL-1.2",
|
|
6
6
|
"scripts": {
|
|
@@ -20,16 +20,16 @@
|
|
|
20
20
|
"kolibri-sample-react-test-build": "test-build.sh"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@leanup/stack": "1.3.
|
|
24
|
-
"@leanup/stack-react": "1.3.
|
|
25
|
-
"@leanup/stack-webpack": "1.3.
|
|
23
|
+
"@leanup/stack": "1.3.48",
|
|
24
|
+
"@leanup/stack-react": "1.3.48",
|
|
25
|
+
"@leanup/stack-webpack": "1.3.48",
|
|
26
26
|
"@public-oss/kolibri-themes": "0.0.3",
|
|
27
|
-
"@public-ui/components": "1.7.0-rc.
|
|
28
|
-
"@public-ui/react": "1.7.0-rc.
|
|
29
|
-
"@public-ui/themes": "1.7.0-rc.
|
|
27
|
+
"@public-ui/components": "1.7.0-rc.7",
|
|
28
|
+
"@public-ui/react": "1.7.0-rc.7",
|
|
29
|
+
"@public-ui/themes": "1.7.0-rc.7",
|
|
30
30
|
"@types/react": "18.2.21",
|
|
31
31
|
"@types/react-dom": "18.2.7",
|
|
32
|
-
"@unocss/preset-
|
|
32
|
+
"@unocss/preset-uno": "0.55.7",
|
|
33
33
|
"@unocss/webpack": "0.55.7",
|
|
34
34
|
"ajv": "8.12.0",
|
|
35
35
|
"chromedriver": "116.0.0",
|
|
@@ -59,8 +59,5 @@
|
|
|
59
59
|
"tsconfig.json",
|
|
60
60
|
"unocss.config.ts",
|
|
61
61
|
"webpack.config.js"
|
|
62
|
-
]
|
|
63
|
-
"publishConfig": {
|
|
64
|
-
"registry": "https://registry.npmjs.org/"
|
|
65
|
-
}
|
|
62
|
+
]
|
|
66
63
|
}
|
package/prettier.config.js
CHANGED
package/public/index.html
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<!
|
|
1
|
+
<!doctype html>
|
|
2
2
|
<html lang="de" dir="ltr">
|
|
3
3
|
<head>
|
|
4
4
|
<title>Code-Samples | KoliBri – Public UI</title>
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
<meta name="robots" content="noindex" />
|
|
21
21
|
<meta name="kolibri" content="dev-mode=true" />
|
|
22
22
|
</head>
|
|
23
|
-
<body
|
|
23
|
+
<body>
|
|
24
24
|
<div id="app"></div>
|
|
25
25
|
<script async src="main.js"></script>
|
|
26
26
|
<noscript>Diese Webseite erfordert, dass Sie JavaScript aktivieren.</noscript>
|
package/src/App.tsx
CHANGED
|
@@ -1,29 +1,18 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
import { Navigate, Route, Routes } from 'react-router-dom';
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
|
+
import { Navigate, Route, Routes, useSearchParams } from 'react-router-dom';
|
|
3
3
|
import { Route as MyRoute, Routes as MyRoutes } from './shares/types';
|
|
4
4
|
|
|
5
5
|
import { Option } from '@public-ui/components';
|
|
6
|
-
import { KolAlert
|
|
7
|
-
import { FC, useState } from 'react';
|
|
6
|
+
import { KolAlert } from '@public-ui/react';
|
|
8
7
|
import { ROUTES } from './shares/routes';
|
|
9
|
-
import {
|
|
8
|
+
import { Theme, THEME_OPTIONS } from './shares/theme';
|
|
10
9
|
import PackageJson from '../package.json';
|
|
11
|
-
import { getTheme,
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
import { getTheme, getThemeName, setStorage, setTheme } from './shares/store';
|
|
11
|
+
import { Sidebar } from './components/Sidebar';
|
|
12
|
+
import { useLocation } from 'react-router';
|
|
14
13
|
|
|
15
14
|
setStorage(localStorage);
|
|
16
15
|
|
|
17
|
-
const getThemeFromLocation = () => {
|
|
18
|
-
if (THEME_REGEX.test(window.location.hash)) {
|
|
19
|
-
const match = window.location.hash.match(THEME_REGEX);
|
|
20
|
-
if (Array.isArray(match) && match.length > 0) {
|
|
21
|
-
return match[0].replace(THEME_REGEX, '$1').toLowerCase();
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return getTheme();
|
|
25
|
-
};
|
|
26
|
-
|
|
27
16
|
const getRouteList = (routes: MyRoutes, offset = '/'): string[] => {
|
|
28
17
|
let list: string[] = [];
|
|
29
18
|
for (const key in routes) {
|
|
@@ -90,167 +79,50 @@ const getRouteTree = (routes: MyRoutes): ReturnType<typeof Route>[] => {
|
|
|
90
79
|
const ROUTE_LIST = getRouteList(ROUTES);
|
|
91
80
|
const ROUTE_TREE = getRouteTree(ROUTES);
|
|
92
81
|
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
const getIndexOfRoute = (str: string) => {
|
|
96
|
-
return ROUTE_LIST.indexOf(clearHash(str));
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
type CustomRoute = { label: string; value: string };
|
|
100
|
-
const componentList: CustomRoute[] = [];
|
|
82
|
+
const componentList: Map<string, Option<string>> = new Map();
|
|
101
83
|
ROUTE_LIST.forEach((route) => {
|
|
102
84
|
const routeSplit = route.split('/');
|
|
103
|
-
if (
|
|
85
|
+
if (!componentList.has(routeSplit[1])) {
|
|
86
|
+
componentList.set(routeSplit[1], {
|
|
87
|
+
label: routeSplit[1],
|
|
88
|
+
value: route,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
104
91
|
});
|
|
105
92
|
|
|
106
|
-
function getComponentFromSample(url: string): string {
|
|
107
|
-
const routeSplit = url.split('/');
|
|
108
|
-
routeSplit[2] = 'basic';
|
|
109
|
-
return routeSplit.join('/');
|
|
110
|
-
}
|
|
111
|
-
|
|
112
93
|
export const App: FC = () => {
|
|
113
|
-
const
|
|
114
|
-
const [
|
|
115
|
-
const
|
|
116
|
-
const
|
|
94
|
+
const routerLocation = useLocation();
|
|
95
|
+
const [searchParams, setSearchParams] = useSearchParams();
|
|
96
|
+
const theme = searchParams.get('theme') ?? getTheme();
|
|
97
|
+
const hideMenus = searchParams.has('hideMenus');
|
|
117
98
|
|
|
118
|
-
|
|
119
|
-
return getComponentFromSample(sample);
|
|
120
|
-
}, [sample]);
|
|
99
|
+
setTheme(theme as Theme); // set for `getTheme` usages within the application
|
|
121
100
|
|
|
122
101
|
document.title = `KoliBri-Handout - ${getThemeName(getTheme())} | v${PackageJson.version}`;
|
|
123
102
|
document.body.setAttribute('class', theme);
|
|
124
103
|
document.body.dataset.theme = theme;
|
|
125
104
|
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}, 500);
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
const componentSelectOn = {
|
|
133
|
-
onChange: (_e: Event, v: unknown) => {
|
|
134
|
-
/**
|
|
135
|
-
* Drop first event as a temporary bugfix for the following issue:
|
|
136
|
-
* When navigated to a component example which is not "basic" it would navigate away from it on the first event, because the select only stores the basic routes.
|
|
137
|
-
* e.g. accordion/header would become accordion/basic.
|
|
138
|
-
* This problem will become obsolete when the select gets replaced with a proper navigation (https://github.com/public-ui/kolibri/issues/5064)
|
|
139
|
-
*/
|
|
140
|
-
if (firstComponentChangeEvent) {
|
|
141
|
-
setFirstComponentChangeEvent(false);
|
|
142
|
-
return;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
const path = (v as string[])[0];
|
|
146
|
-
setSample(path);
|
|
147
|
-
window.location.href = `#${path}?theme=${theme}`;
|
|
148
|
-
},
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
const on = {
|
|
152
|
-
onChange: (_event: Event, value: unknown) => {
|
|
153
|
-
if (active) {
|
|
154
|
-
value = Array.isArray(value) ? value[0] : value;
|
|
155
|
-
setTheme(value as Theme);
|
|
156
|
-
window.location.href =
|
|
157
|
-
window.location.href
|
|
158
|
-
.replace(THEME_REGEX, '')
|
|
159
|
-
.replace(/(\?|&{1,})$/g, '')
|
|
160
|
-
.replace(/&{2,}/g, '&') + `?theme=${value as string}`;
|
|
161
|
-
window.location.reload();
|
|
162
|
-
}
|
|
163
|
-
},
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
const next = {
|
|
167
|
-
onClick: () => {
|
|
168
|
-
let idx = getIndexOfRoute(window.location.hash);
|
|
169
|
-
if (idx >= ROUTE_LIST.length - 1) {
|
|
170
|
-
idx = 0;
|
|
171
|
-
} else {
|
|
172
|
-
idx += 1;
|
|
173
|
-
}
|
|
174
|
-
setSample(clearHash(ROUTE_LIST[idx]));
|
|
175
|
-
window.location.href = `#${ROUTE_LIST[idx]}?theme=${theme}`;
|
|
176
|
-
},
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
const prev = {
|
|
180
|
-
onClick: () => {
|
|
181
|
-
let idx = getIndexOfRoute(window.location.hash);
|
|
182
|
-
if (idx <= 0) {
|
|
183
|
-
idx = ROUTE_LIST.length - 1;
|
|
184
|
-
} else {
|
|
185
|
-
idx -= 1;
|
|
186
|
-
}
|
|
187
|
-
setSample(clearHash(ROUTE_LIST[idx]));
|
|
188
|
-
window.location.href = `#${ROUTE_LIST[idx]}?theme=${theme}`;
|
|
189
|
-
},
|
|
105
|
+
const handleThemeChange = (theme: unknown) => {
|
|
106
|
+
setSearchParams({ theme: theme as string });
|
|
107
|
+
window.location.reload();
|
|
190
108
|
};
|
|
191
109
|
|
|
192
110
|
return (
|
|
193
|
-
<div className=
|
|
194
|
-
|
|
195
|
-
<
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
<KolVersion _version={PackageJson.version}></KolVersion>
|
|
206
|
-
</dd>
|
|
207
|
-
</dl>
|
|
208
|
-
{active && (
|
|
209
|
-
<>
|
|
210
|
-
<KolButton
|
|
211
|
-
_ariaLabel="Weiter zum nächsten Komponenten-Beispiel"
|
|
212
|
-
_icon="codicon codicon-arrow-right"
|
|
213
|
-
_hideLabel
|
|
214
|
-
_label="Weiter"
|
|
215
|
-
_on={next}
|
|
216
|
-
_tooltipAlign="left"
|
|
217
|
-
/>
|
|
218
|
-
<KolButton
|
|
219
|
-
_ariaLabel="Weiter zum nächsten Komponenten-Beispiel"
|
|
220
|
-
_icon="codicon codicon-arrow-left"
|
|
221
|
-
_hideLabel
|
|
222
|
-
_label="Zurück"
|
|
223
|
-
_on={prev}
|
|
224
|
-
_tooltipAlign="right"
|
|
225
|
-
_variant="ghost"
|
|
226
|
-
/>
|
|
227
|
-
</>
|
|
228
|
-
)}
|
|
229
|
-
<KolSelect
|
|
230
|
-
className="col-span-2 sm:col-auto"
|
|
231
|
-
_disabled={!active}
|
|
232
|
-
_hideLabel
|
|
233
|
-
_label="Komponente wechseln"
|
|
234
|
-
_id="theme-toggle"
|
|
235
|
-
_list={componentList}
|
|
236
|
-
_on={componentSelectOn}
|
|
237
|
-
_value={[currentComponent]}
|
|
238
|
-
></KolSelect>
|
|
239
|
-
<KolSelect
|
|
240
|
-
_label="Theme wechseln"
|
|
241
|
-
className="col-span-2 sm:col-auto"
|
|
242
|
-
_hideLabel
|
|
243
|
-
_disabled={!active}
|
|
244
|
-
_id="theme-toggle"
|
|
245
|
-
_list={THEME_OPTIONS}
|
|
246
|
-
_on={on}
|
|
247
|
-
_value={[theme]}
|
|
248
|
-
></KolSelect>
|
|
249
|
-
</div>
|
|
250
|
-
<hr aria-hidden="true" />
|
|
111
|
+
<div className={!hideMenus ? 'app-container' : ''} data-theme={theme}>
|
|
112
|
+
{!hideMenus && (
|
|
113
|
+
<Sidebar
|
|
114
|
+
version={PackageJson.version}
|
|
115
|
+
theme={theme}
|
|
116
|
+
sample={routerLocation.pathname}
|
|
117
|
+
routes={ROUTES}
|
|
118
|
+
routeList={ROUTE_LIST}
|
|
119
|
+
onThemeChange={handleThemeChange}
|
|
120
|
+
/>
|
|
121
|
+
)}
|
|
122
|
+
|
|
251
123
|
<div className="p-4">
|
|
252
124
|
<Routes>
|
|
253
|
-
{
|
|
125
|
+
{ROUTE_TREE}
|
|
254
126
|
<Route path="*" element={<KolAlert _type="info">This code example has not been migrated yet - it's coming soon!</KolAlert>} />
|
|
255
127
|
</Routes>
|
|
256
128
|
</div>
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import React, { FC, useState } from 'react';
|
|
2
|
+
import { KolButton, KolHeading, KolLink, KolSelect, KolVersion } from '@public-ui/react';
|
|
3
|
+
import { THEME_OPTIONS } from '../shares/theme';
|
|
4
|
+
import { Routes } from '../shares/types';
|
|
5
|
+
|
|
6
|
+
type Props = {
|
|
7
|
+
version: string;
|
|
8
|
+
theme: string;
|
|
9
|
+
routes: Routes;
|
|
10
|
+
routeList: string[];
|
|
11
|
+
sample: string;
|
|
12
|
+
onThemeChange: (theme: unknown) => void;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const Sidebar: FC<Props> = ({ version, theme, routes, routeList, sample, onThemeChange }) => {
|
|
16
|
+
/* KolSelect calls onChange initially by design - work around this with a state variable */
|
|
17
|
+
const [isFirstThemeSelectChange, setIsFirstThemeSelectChange] = useState(true);
|
|
18
|
+
|
|
19
|
+
const getIndexOfSample = () => routeList.indexOf(sample);
|
|
20
|
+
const formatSampleAsLabel = () => sample.replace(/\//g, ' ');
|
|
21
|
+
|
|
22
|
+
const handleThemeSelectChange = (_event: Event, value: unknown) => {
|
|
23
|
+
if (isFirstThemeSelectChange) {
|
|
24
|
+
setIsFirstThemeSelectChange(false);
|
|
25
|
+
} else {
|
|
26
|
+
onThemeChange((value as [string])[0]);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const handleLinkClick = (event: Event) => {
|
|
31
|
+
location.replace((event.target as HTMLLinkElement).href); // KoliBri prevents the default click behavior as soon as an event listener is set, so we need to reimplement it.
|
|
32
|
+
document.documentElement.scrollIntoView({ behavior: 'smooth' });
|
|
33
|
+
// @todo set focus?
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const handlePreviousClick = () => {
|
|
37
|
+
const currentIndex = getIndexOfSample();
|
|
38
|
+
const nextIndex = currentIndex === 0 ? routeList.length - 1 : currentIndex - 1;
|
|
39
|
+
location.replace(`#${routeList[nextIndex]}`);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const handleNextClick = () => {
|
|
43
|
+
const currentIndex = getIndexOfSample();
|
|
44
|
+
const nextIndex = currentIndex === routeList.length - 1 ? 0 : currentIndex + 1;
|
|
45
|
+
location.replace(`#${routeList[nextIndex]}`);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<aside className="app-sidebar p-4">
|
|
50
|
+
<div className="flex flex-justify-between flex-items-center">
|
|
51
|
+
<KolHeading _label="KoliBri React"></KolHeading>
|
|
52
|
+
<KolVersion _version={version}></KolVersion>
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
<KolSelect _label="Theme wählen" _list={THEME_OPTIONS} _on={{ onChange: handleThemeSelectChange }} _value={[theme]} class="mt"></KolSelect>
|
|
56
|
+
|
|
57
|
+
<KolHeading _label="Komponenten" _level={2} className="block mt"></KolHeading>
|
|
58
|
+
<div className="flex flex-justify-between flex-items-center mt">
|
|
59
|
+
<KolButton _icon="codicon codicon-arrow-left" _hideLabel _label="Vorherige Komponente auswählen" _on={{ onClick: handlePreviousClick }} />
|
|
60
|
+
{formatSampleAsLabel()} ({getIndexOfSample() + 1}/{routeList.length})
|
|
61
|
+
<KolButton _icon="codicon codicon-arrow-right" _hideLabel _label="Nächste Komponente auswählen" _on={{ onClick: handleNextClick }} />
|
|
62
|
+
</div>
|
|
63
|
+
<nav className="block mt">
|
|
64
|
+
<ul className="m0 p0 list-inside">
|
|
65
|
+
{Object.entries(routes).map(([parentName, children]) => (
|
|
66
|
+
<li key={parentName} className="mt-2">
|
|
67
|
+
{parentName}
|
|
68
|
+
<ul className="list-inside ml p0">
|
|
69
|
+
{Object.keys(children).map((childName) => (
|
|
70
|
+
<li key={`${parentName}/${childName}`}>
|
|
71
|
+
<KolLink _label={childName} _href={`#/${parentName}/${childName}`} _on={{ onClick: handleLinkClick }} />
|
|
72
|
+
</li>
|
|
73
|
+
))}
|
|
74
|
+
</ul>
|
|
75
|
+
</li>
|
|
76
|
+
))}
|
|
77
|
+
</ul>
|
|
78
|
+
</nav>
|
|
79
|
+
</aside>
|
|
80
|
+
);
|
|
81
|
+
};
|
package/src/shares/routes.ts
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import { ABBR_ROUTES } from '../
|
|
2
|
-
import { ACCORDION_ROUTES } from '../
|
|
3
|
-
import { ALERT_ROUTES } from '../
|
|
4
|
-
import { AVATAR_ROUTES } from '../
|
|
5
|
-
import { BADGE_ROUTES } from '../
|
|
6
|
-
import { BREADCRUMB_ROUTES } from '../
|
|
7
|
-
import { BUTTON_GROUP_ROUTES } from '../
|
|
8
|
-
import { BUTTON_LINK_ROUTES } from '../
|
|
9
|
-
import { BUTTON_ROUTES } from '../
|
|
10
|
-
import { CARD_ROUTES } from '../
|
|
11
|
-
import { DETAILS_ROUTES } from '../
|
|
12
|
-
import { FORM_ROUTES } from '../
|
|
13
|
-
import { HANDOUT_ROUTES } from '../
|
|
14
|
-
import { HEADING_ROUTES } from '../
|
|
15
|
-
import { ICON_ROUTES } from '../
|
|
16
|
-
import { INDENTED_ROUTES } from '../
|
|
17
|
-
import { INPUT_CHECKBOX_ROUTES } from '../
|
|
18
|
-
import { INPUT_COLOR_ROUTES } from '../
|
|
19
|
-
import { INPUT_DATE_ROUTES } from '../
|
|
20
|
-
import { INPUT_EMAIL_ROUTES } from '../
|
|
21
|
-
import { INPUT_FILE_ROUTES } from '../
|
|
22
|
-
import { INPUT_NUMBER_ROUTES } from '../
|
|
23
|
-
import { INPUT_PASSWORD_ROUTES } from '../
|
|
24
|
-
import { INPUT_RADIO_ROUTES } from '../
|
|
25
|
-
import { INPUT_RANGE_ROUTES } from '../
|
|
26
|
-
import { INPUT_TEXT_ROUTES } from '../
|
|
27
|
-
import { LINK_BUTTON_ROUTES } from '../
|
|
28
|
-
import { LINK_GROUP_ROUTES } from '../
|
|
29
|
-
import { LINK_ROUTES } from '../
|
|
30
|
-
import { NAV_ROUTES } from '../
|
|
31
|
-
import { PAGINATION_ROUTES } from '../
|
|
32
|
-
import { POPOVER_ROUTES } from '../
|
|
33
|
-
import { PROGRESS_ROUTES } from '../
|
|
34
|
-
import { SELECT_ROUTES } from '../
|
|
35
|
-
import { SKIP_NAV_ROUTES } from '../
|
|
36
|
-
import { SPIN_ROUTES } from '../
|
|
37
|
-
import { SPLIT_BUTTON_ROUTES } from '../
|
|
38
|
-
import { TABLE_ROUTES } from '../
|
|
39
|
-
import { TEXTAREA_ROUTES } from '../
|
|
40
|
-
import { TOAST_ROUTES } from '../
|
|
41
|
-
import { VERSION_ROUTES } from '../
|
|
1
|
+
import { ABBR_ROUTES } from '../components/abbr/routes';
|
|
2
|
+
import { ACCORDION_ROUTES } from '../components/accordion/routes';
|
|
3
|
+
import { ALERT_ROUTES } from '../components/alert/routes';
|
|
4
|
+
import { AVATAR_ROUTES } from '../components/avatar/routes';
|
|
5
|
+
import { BADGE_ROUTES } from '../components/badge/routes';
|
|
6
|
+
import { BREADCRUMB_ROUTES } from '../components/breadcrumb/routes';
|
|
7
|
+
import { BUTTON_GROUP_ROUTES } from '../components/button-group/routes';
|
|
8
|
+
import { BUTTON_LINK_ROUTES } from '../components/button-link/routes';
|
|
9
|
+
import { BUTTON_ROUTES } from '../components/button/routes';
|
|
10
|
+
import { CARD_ROUTES } from '../components/card/routes';
|
|
11
|
+
import { DETAILS_ROUTES } from '../components/details/routes';
|
|
12
|
+
import { FORM_ROUTES } from '../components/form/routes';
|
|
13
|
+
import { HANDOUT_ROUTES } from '../components/handout/routes';
|
|
14
|
+
import { HEADING_ROUTES } from '../components/heading/routes';
|
|
15
|
+
import { ICON_ROUTES } from '../components/icon/routes';
|
|
16
|
+
import { INDENTED_ROUTES } from '../components/indented-text/routes';
|
|
17
|
+
import { INPUT_CHECKBOX_ROUTES } from '../components/input-checkbox/routes';
|
|
18
|
+
import { INPUT_COLOR_ROUTES } from '../components/input-color/routes';
|
|
19
|
+
import { INPUT_DATE_ROUTES } from '../components/input-date/routes';
|
|
20
|
+
import { INPUT_EMAIL_ROUTES } from '../components/input-email/routes';
|
|
21
|
+
import { INPUT_FILE_ROUTES } from '../components/input-file/routes';
|
|
22
|
+
import { INPUT_NUMBER_ROUTES } from '../components/input-number/routes';
|
|
23
|
+
import { INPUT_PASSWORD_ROUTES } from '../components/input-password/routes';
|
|
24
|
+
import { INPUT_RADIO_ROUTES } from '../components/input-radio/routes';
|
|
25
|
+
import { INPUT_RANGE_ROUTES } from '../components/input-range/routes';
|
|
26
|
+
import { INPUT_TEXT_ROUTES } from '../components/input-text/routes';
|
|
27
|
+
import { LINK_BUTTON_ROUTES } from '../components/link-button/routes';
|
|
28
|
+
import { LINK_GROUP_ROUTES } from '../components/link-group/routes';
|
|
29
|
+
import { LINK_ROUTES } from '../components/link/routes';
|
|
30
|
+
import { NAV_ROUTES } from '../components/nav/routes';
|
|
31
|
+
import { PAGINATION_ROUTES } from '../components/pagination/routes';
|
|
32
|
+
import { POPOVER_ROUTES } from '../components/popover/routes';
|
|
33
|
+
import { PROGRESS_ROUTES } from '../components/progress/routes';
|
|
34
|
+
import { SELECT_ROUTES } from '../components/select/routes';
|
|
35
|
+
import { SKIP_NAV_ROUTES } from '../components/skip-nav/routes';
|
|
36
|
+
import { SPIN_ROUTES } from '../components/spin/routes';
|
|
37
|
+
import { SPLIT_BUTTON_ROUTES } from '../components/split-button/routes';
|
|
38
|
+
import { TABLE_ROUTES } from '../components/table/routes';
|
|
39
|
+
import { TEXTAREA_ROUTES } from '../components/textarea/routes';
|
|
40
|
+
import { TOAST_ROUTES } from '../components/toast/routes';
|
|
41
|
+
import { VERSION_ROUTES } from '../components/version/routes';
|
|
42
42
|
import { Routes } from './types';
|
|
43
43
|
|
|
44
44
|
export const ROUTES: Routes = {
|
package/src/shares/store.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isTheme, Store, Theme } from './theme';
|
|
2
|
-
import PackageJson from '
|
|
2
|
+
import PackageJson from '@public-ui/components/package.json';
|
|
3
3
|
import { THEME_OPTIONS } from './theme';
|
|
4
4
|
import { Option } from '@public-ui/components';
|
|
5
5
|
|
|
@@ -19,7 +19,7 @@ class StaticStorage {
|
|
|
19
19
|
|
|
20
20
|
const STORE: Store = {
|
|
21
21
|
darkMode: false,
|
|
22
|
-
theme: '
|
|
22
|
+
theme: 'default',
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
let STORAGE: Storage;
|
package/src/style.scss
CHANGED
|
@@ -19,71 +19,20 @@ hr {
|
|
|
19
19
|
grid-template-columns: auto auto;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
.
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
.app-container {
|
|
23
|
+
display: grid;
|
|
24
|
+
grid-template-columns: 360px auto;
|
|
25
|
+
height: 100%;
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
.toolbar dl {
|
|
32
|
-
order: 2;
|
|
33
|
-
display: flex;
|
|
34
|
-
gap: 0.5em;
|
|
35
|
-
justify-self: start;
|
|
36
|
-
place-items: center;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.toolbar dd {
|
|
40
|
-
margin: 0;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.toolbar kol-select {
|
|
44
|
-
order: 3;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.toolbar kol-button[_label="Weiter"] {
|
|
48
|
-
order: 4;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
@media only screen and (max-width: 1024px) {
|
|
52
|
-
.toolbar {
|
|
53
|
-
display: grid;
|
|
54
|
-
gap: 1rem;
|
|
55
|
-
grid-template-columns: 1fr 1fr;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
.toolbar kol-button[_label="Zurück"] {
|
|
59
|
-
order: 3;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
.toolbar dl {
|
|
63
|
-
order: 1;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
.toolbar kol-select {
|
|
67
|
-
order: 2;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
.toolbar kol-button[_label="Weiter"] {
|
|
71
|
-
order: 4;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
@media only screen and (max-width: 512px) {
|
|
76
|
-
|
|
77
|
-
.toolbar dl,
|
|
78
|
-
.toolbar kol-select {
|
|
79
|
-
grid-column: span 2;
|
|
80
|
-
}
|
|
28
|
+
.app-sidebar {
|
|
29
|
+
border-right: 1px solid gray;
|
|
30
|
+
font-family: sans-serif;
|
|
81
31
|
}
|
|
82
32
|
|
|
83
33
|
@media print {
|
|
84
|
-
|
|
85
34
|
.no-print,
|
|
86
35
|
.no-print * {
|
|
87
36
|
display: none !important;
|
|
88
37
|
}
|
|
89
|
-
}
|
|
38
|
+
}
|
package/unocss.config.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineConfig } from '@unocss/webpack';
|
|
2
|
-
import {
|
|
2
|
+
import { presetUno } from '@unocss/preset-uno';
|
|
3
3
|
|
|
4
4
|
// ts-prune-ignore-next
|
|
5
5
|
export default defineConfig({
|
|
6
|
-
presets: [
|
|
6
|
+
presets: [presetUno()],
|
|
7
7
|
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|