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.
@@ -1,5 +1,6 @@
1
+ import React from 'react';
1
2
  type ThemeProps = {
2
3
  vendor?: string;
3
4
  };
4
- export default function useTheme({ vendor }: ThemeProps): any;
5
+ export default function MyComponent({ vendor }: ThemeProps): React.JSX.Element;
5
6
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "willba-component-library",
3
- "version": "0.0.41",
3
+ "version": "0.0.42",
4
4
  "description": "A stroybook 6 with TypeScript demo",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.esm.js",
@@ -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="filter-bar">
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')}
@@ -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 useTheme({ vendor }: ThemeProps) {
8
- const [cssModule, setCssModule] = useState<any>(null)
9
-
41
+ export default function MyComponent({ vendor }: ThemeProps) {
10
42
  useEffect(() => {
11
- async function importCss() {
12
- if (vendor === 'Kisakallio') {
13
- const kisakallioCss = await import('./Kisakallio.css')
14
- setCssModule(kisakallioCss.default)
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
- return cssModule
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
  }
@@ -1,5 +0,0 @@
1
- // cssModules.d.ts
2
- declare module '*.css' {
3
- const classes: { [key: string]: string }
4
- export default classes
5
- }