tera-system-ui 0.0.28 → 0.0.33

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.
@@ -78,5 +78,6 @@ export interface AvatarProps extends AvatarVariants {
78
78
  src?: string;
79
79
  ref?: any;
80
80
  userUid?: string;
81
+ apiUrl?: string;
81
82
  }
82
83
  export {};
@@ -12,6 +12,7 @@
12
12
  border = true,
13
13
  ref = $bindable(),
14
14
  userUid,
15
+ apiUrl,
15
16
  ...props
16
17
  }: AvatarProps = $props();
17
18
 
@@ -21,7 +22,7 @@
21
22
  isError = true
22
23
  }
23
24
 
24
- let imgUrl = src ? src : userUid ? getUserAvatarUrl(userUid) : undefined
25
+ let imgUrl = src ? src : userUid ? getUserAvatarUrl(userUid, apiUrl) : undefined
25
26
  </script>
26
27
 
27
28
  <div bind:this={ref}
@@ -4,5 +4,8 @@ type LanguagePickerButtonVariants = VariantProps<typeof styles>;
4
4
  export interface LanguagePickerButtonProps extends LanguagePickerButtonVariants {
5
5
  children?: any;
6
6
  class?: string;
7
+ language?: string;
8
+ supportLanguages?: string[];
9
+ basePath?: string;
7
10
  }
8
11
  export {};
@@ -9,6 +9,10 @@
9
9
  let {
10
10
  children,
11
11
  onLangSelect,
12
+
13
+ language,
14
+ supportLanguages,
15
+ basePath,
12
16
  ...props
13
17
  }: LanguagePickerButtonProps & {
14
18
  onLangSelect: (langCode: string) => void
@@ -16,6 +20,10 @@
16
20
 
17
21
  let context = getGlobalContext()
18
22
 
23
+ supportLanguages = supportLanguages ?? context.supportLanguages!;
24
+ language = language ?? context.language
25
+ basePath = basePath ?? context.basePath
26
+
19
27
 
20
28
  const LANGUAGE_LIST = [
21
29
  {
@@ -59,27 +67,29 @@
59
67
  flag: 'vietnam'
60
68
  }
61
69
  // @ts-ignore
62
- ].filter(lang => context.supportLanguages!.includes(lang.code))
70
+ ].filter(lang => supportLanguages.includes(lang.code))
63
71
 
64
72
 
65
- let currentLangItem = $derived(LANGUAGE_LIST.find(l => l.code === context.language)!)
73
+ let currentLangItem = $derived(LANGUAGE_LIST.find(l => l.code === language)!)
66
74
 
67
75
 
68
76
  function getFlagUrl(flag: string) {
69
77
  if (flag === 'spain') {
70
- return `${context.basePath ?? ''}/world-flags/${flag}.png`
78
+ return `${basePath ?? ''}/world-flags/${flag}.png`
71
79
  }
72
- return `${context.basePath ?? ''}/world-flags/${flag}.svg`
80
+ return `${basePath ?? ''}/world-flags/${flag}.svg`
73
81
  }
74
82
 
75
83
  let openDialog = $state(false)
84
+
85
+ let flagUrl = $derived(getFlagUrl(currentLangItem.flag))
76
86
  </script>
77
87
 
78
88
  <!--add component here-->
79
89
  <button onclick={() => {openDialog = true}}
80
90
  class="h-8 flex items-center bg-neutral-token-4 text-neutral-token-9 rounded-full ps-2 pe-1 hover:bg-neutral-token-5 transition-all duration-element-react">
81
91
  <IconLanguage class="size-icon-xs"/>
82
- <img class="size-6 flag-img" src={getFlagUrl(currentLangItem.flag)} alt={currentLangItem.flag}>
92
+ <img class="size-6 flag-img" src={flagUrl} alt={currentLangItem.flag}>
83
93
  </button>
84
94
 
85
95
  <Dialog bind:open={openDialog} class="text-neutral-token-13" size="xs" staticRender>
@@ -93,7 +103,7 @@
93
103
  onLangSelect?.(lang.code)
94
104
  openDialog = false
95
105
  }}
96
- data-selected={lang.code === context.language ? '' : undefined}>
106
+ data-selected={lang.code === language ? '' : undefined}>
97
107
  <div class="flex items-center gap-2">
98
108
  <img class="size-8 flag-img" src={getFlagUrl(lang.flag)} alt={currentLangItem.flag} loading="lazy">
99
109
  {lang.label}
@@ -4,6 +4,7 @@ type SideNavigationVariants = VariantProps<typeof styles>;
4
4
  export interface SideNavigationProps extends SideNavigationVariants {
5
5
  children?: any;
6
6
  class?: string;
7
+ sideNavHref?: string;
7
8
  }
8
9
  export declare const SCREEN_BREAK_POINTS: {
9
10
  sm: number;
@@ -19,7 +19,7 @@
19
19
 
20
20
  import {getGlobalContext} from "../tera-ui-context/global-context";
21
21
 
22
- let {children, ...props}: SideNavigationProps = $props();
22
+ let {children, sideNavHref, ...props}: SideNavigationProps = $props();
23
23
 
24
24
  let temporaryExpand: any = undefined
25
25
 
@@ -47,15 +47,12 @@
47
47
 
48
48
  let globalContext = getGlobalContext()
49
49
 
50
- console.log('SideNavigation get global context', globalContext)
50
+ sideNavHref = sideNavHref || globalContext?.sideNavHref
51
51
 
52
52
  function isSelected(href: string) {
53
- const pathname = globalContext?.sideNavHref
54
- return pathname?.startsWith(href)
53
+ return sideNavHref?.startsWith(href)
55
54
  }
56
55
 
57
-
58
-
59
56
  const NAV_ITEM = [
60
57
  {
61
58
  href: '/calculator',
@@ -2,8 +2,6 @@
2
2
  import {type TeraUiContextProps} from "./TeraUiContext";
3
3
  import {setGlobalContext} from "./global-context";
4
4
  import {setLanguageTag} from "../../paraglide/runtime";
5
- import * as m from '../../paraglide/messages'
6
-
7
5
 
8
6
  let {
9
7
  children,
@@ -12,17 +10,19 @@
12
10
  ...props
13
11
  }: TeraUiContextProps = $props();
14
12
 
15
-
16
13
  setGlobalContext({
17
14
  supportLanguages,
18
15
  language,
19
16
  ...props
20
17
  })
21
18
 
22
- setLanguageTag(language)
23
- console.log('setLanguageTag', language)
24
- console.log('test translate', m.text_select_language())
19
+ console.log('tera-system-ui', 'TeraUIContext props', {
20
+ supportLanguages,
21
+ language,
22
+ ...props
23
+ })
25
24
 
25
+ setLanguageTag(language)
26
26
  </script>
27
27
 
28
28
  {@render children()}
@@ -12,6 +12,7 @@ export function setGlobalContext(data) {
12
12
  }
13
13
  export function getGlobalContext() {
14
14
  let context = getContext('globalContext') || get(globalContextStore);
15
+ console.log('tera-system-ui', 'getGlobalContext', context);
15
16
  if (!context) {
16
17
  console.error('tera-system-ui', 'Not set global context yet!', 'Using default context data');
17
18
  return {
@@ -1,2 +1,2 @@
1
1
  export declare function extractShortUsernameFromEmail(email: string): string;
2
- export declare function getUserAvatarUrl(userUid: string): string;
2
+ export declare function getUserAvatarUrl(userUid: string, apiUrl?: string): string;
@@ -14,7 +14,7 @@ export function extractShortUsernameFromEmail(email) {
14
14
  shortForm = shortForm.slice(0, 4).toUpperCase();
15
15
  return shortForm || '?';
16
16
  }
17
- export function getUserAvatarUrl(userUid) {
18
- let baseUrl = `${getGlobalContext().apiUrl || 'https://hoidap.xyz/api/v1'}/users`;
17
+ export function getUserAvatarUrl(userUid, apiUrl) {
18
+ let baseUrl = `${apiUrl || getGlobalContext().apiUrl || 'https://hoidap.xyz/api/v1'}/users`;
19
19
  return `${baseUrl}/avatar/${encodeURI(userUid)}`;
20
20
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tera-system-ui",
3
- "version": "0.0.28",
3
+ "version": "0.0.33",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "npm run customPrepublish && npm run generate-index && vite build && npm run package && npm run postpublish",
@@ -65,7 +65,7 @@
65
65
  "@storybook/addon-interactions": "^8.4.4",
66
66
  "@storybook/addon-links": "^8.4.4",
67
67
  "@storybook/addon-styling": "^1.3.7",
68
- "@storybook/addon-svelte-csf": "^5.0.0-next.8",
68
+ "@storybook/addon-svelte-csf": "^5.0.0-next.11",
69
69
  "@storybook/addon-themes": "^8.4.4",
70
70
  "@storybook/addon-viewport": "^8.4.4",
71
71
  "@storybook/blocks": "^8.4.4",