willba-component-library 0.0.41 → 0.0.42
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/lib/index.esm.js +65 -131
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +65 -131
- package/lib/index.js.map +1 -1
- package/lib/index.umd.js +65 -131
- package/lib/index.umd.js.map +1 -1
- package/lib/themes/useTheme.d.ts +2 -1
- package/package.json +1 -1
- package/src/components/FilterBar/FilterBar.tsx +2 -2
- package/src/themes/useTheme.tsx +50 -17
- package/src/themes/cssModules.d.ts +0 -5
package/lib/themes/useTheme.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -21,7 +21,7 @@ type FilterBarProps = {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export default function FilterBar({ vendor, language }: FilterBarProps) {
|
|
24
|
-
useTheme({ vendor })
|
|
24
|
+
const cssLoaded = useTheme({ vendor })
|
|
25
25
|
|
|
26
26
|
const [rerenderKey, setRerenderKey] = useState(0)
|
|
27
27
|
|
|
@@ -49,7 +49,7 @@ export default function FilterBar({ vendor, language }: FilterBarProps) {
|
|
|
49
49
|
} = useFilterBar()
|
|
50
50
|
|
|
51
51
|
return (
|
|
52
|
-
<div className=
|
|
52
|
+
<div className={`filter-bar ${cssLoaded ? 'dynamic-theme-class' : ''}`}>
|
|
53
53
|
<div className="filter-bar-header">
|
|
54
54
|
<SelectButton
|
|
55
55
|
label={t('calendar.startDate')}
|
package/src/themes/useTheme.tsx
CHANGED
|
@@ -1,27 +1,60 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react'
|
|
1
|
+
// import React, { useEffect, useState } from 'react'
|
|
2
2
|
|
|
3
|
+
// type ThemeProps = {
|
|
4
|
+
// vendor?: string
|
|
5
|
+
// }
|
|
6
|
+
|
|
7
|
+
// export default function useTheme({ vendor }: ThemeProps) {
|
|
8
|
+
// const [cssLoaded, setCssLoaded] = useState(false)
|
|
9
|
+
|
|
10
|
+
// useEffect(() => {
|
|
11
|
+
// async function loadThemeCSS() {
|
|
12
|
+
// try {
|
|
13
|
+
// let cssUrl = ''
|
|
14
|
+
|
|
15
|
+
// if (vendor === 'Kisakallio') {
|
|
16
|
+
// cssUrl = './Kisakallio.css'
|
|
17
|
+
// } else if (vendor === 'Pajulahti') {
|
|
18
|
+
// cssUrl = './Pajulahti.css'
|
|
19
|
+
// } else {
|
|
20
|
+
// cssUrl = './Default.css'
|
|
21
|
+
// }
|
|
22
|
+
|
|
23
|
+
// await loadCSS(cssUrl)
|
|
24
|
+
// setCssLoaded(true)
|
|
25
|
+
// } catch (error) {
|
|
26
|
+
// console.error('Error loading CSS:', error)
|
|
27
|
+
// }
|
|
28
|
+
// }
|
|
29
|
+
|
|
30
|
+
// loadThemeCSS()
|
|
31
|
+
// }, [vendor])
|
|
32
|
+
|
|
33
|
+
// return cssLoaded
|
|
34
|
+
// }
|
|
35
|
+
|
|
36
|
+
import React, { useEffect } from 'react'
|
|
3
37
|
type ThemeProps = {
|
|
4
38
|
vendor?: string
|
|
5
39
|
}
|
|
6
40
|
|
|
7
|
-
export default function
|
|
8
|
-
const [cssModule, setCssModule] = useState<any>(null)
|
|
9
|
-
|
|
41
|
+
export default function MyComponent({ vendor }: ThemeProps) {
|
|
10
42
|
useEffect(() => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
} else if (vendor === 'Pajulahti') {
|
|
16
|
-
const pajulahtiCss = await import('./Pajulahti.css')
|
|
17
|
-
setCssModule(pajulahtiCss.default)
|
|
18
|
-
} else {
|
|
19
|
-
return
|
|
20
|
-
}
|
|
43
|
+
if (vendor === 'Kisakallio') {
|
|
44
|
+
addCSSFile('./Kisakallio.css')
|
|
45
|
+
} else {
|
|
46
|
+
addCSSFile('./Default.css')
|
|
21
47
|
}
|
|
22
|
-
|
|
23
|
-
importCss()
|
|
24
48
|
}, [vendor])
|
|
25
49
|
|
|
26
|
-
|
|
50
|
+
// Rest of your component code
|
|
51
|
+
return <div>My Component</div>
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const addCSSFile = (href: string) => {
|
|
55
|
+
const link = document.createElement('link')
|
|
56
|
+
link.rel = 'stylesheet'
|
|
57
|
+
link.type = 'text/css'
|
|
58
|
+
link.href = href
|
|
59
|
+
document.head.appendChild(link)
|
|
27
60
|
}
|