@hyvor/design 2.0.17 → 2.0.19

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.
@@ -70,10 +70,23 @@ export interface ResolvedLicense {
70
70
  type: 'enterprise_contract' | 'subscription' | 'trial' | 'expired' | 'none';
71
71
  license: Record<string, number | boolean> | null;
72
72
  subscription: null | {
73
+ id: number;
74
+ status: string;
75
+ monthly_price: number;
76
+ is_annual: boolean;
77
+ plan: string;
78
+ plan_version: number;
73
79
  plan_readable_name: string;
74
80
  cancel_at: null | number;
81
+ is_legacy_paddle: boolean;
75
82
  };
76
83
  trial_ends_at: null | number;
84
+ complimentary_licenses: ResolvedComplimentaryLicense[];
85
+ }
86
+ export interface ResolvedComplimentaryLicense {
87
+ provider: string;
88
+ type: 'trial' | 'subscription';
89
+ license: Record<string, number | boolean>;
77
90
  }
78
91
  export interface OrganizationMember {
79
92
  id: number;
@@ -4,6 +4,7 @@
4
4
  import Tooltip from '../../../components/Tooltip/Tooltip.svelte';
5
5
  import IconBuilding from '@hyvor/icons/IconBuilding';
6
6
  import type { Component } from 'svelte';
7
+ import { PRODUCTS } from '../BarProducts/products.js';
7
8
 
8
9
  let { name } = $props();
9
10
 
@@ -36,11 +37,11 @@
36
37
  interface Config {
37
38
  name: string;
38
39
  tooltip: string;
39
- tagColor: 'green' | 'blue' | 'red' | 'orange';
40
+ tagColor: 'green' | 'blue' | 'red' | 'orange' | 'default';
40
41
  tagIcon?: Component;
41
42
  }
42
43
 
43
- let config: Config | null = $derived.by(() => {
44
+ let mainConfig: Config | null = $derived.by(() => {
44
45
  if (!license) {
45
46
  return null;
46
47
  }
@@ -79,6 +80,11 @@
79
80
  }
80
81
 
81
82
  if (license.type === 'expired') {
83
+ if (license.complimentary_licenses.length > 0) {
84
+ // if the org has a complimentary license, we do not show the "Expired" tag to prevent confusing the user
85
+ return null;
86
+ }
87
+
82
88
  return {
83
89
  name: `License Expired`,
84
90
  tooltip: `Your organization's license for ${name} has expired. Please renew or upgrade to continue using the service.`,
@@ -88,30 +94,83 @@
88
94
 
89
95
  return null;
90
96
  });
97
+
98
+ let complimentaryConfig: Config | null = $derived.by(() => {
99
+ if (!license) {
100
+ return null;
101
+ }
102
+
103
+ if (!license.complimentary_licenses.length) {
104
+ return null;
105
+ }
106
+
107
+ // for now, we only care about the 1st one
108
+ // we may later add other licenses
109
+ const complimentaryLicense = license.complimentary_licenses[0];
110
+ const providerName = PRODUCTS[complimentaryLicense.provider].name;
111
+
112
+ return {
113
+ name: 'Complimentary',
114
+ tooltip: `Your organization has a complimentary license for ${name} thanks to your ${providerName} ${complimentaryLicense.type}.`,
115
+ tagColor: 'default'
116
+ };
117
+ });
91
118
  </script>
92
119
 
93
- {#if config}
94
- <a class="wrap" href="/console/billing">
95
- <Tooltip position="bottom">
96
- {#snippet tooltip()}
97
- {config.tooltip}
98
- {/snippet}
99
- <Tag color={config.tagColor}>
100
- {#snippet start()}
101
- {#if config.tagIcon}
102
- <config.tagIcon size={10} />
103
- {/if}
120
+ <div class="outer">
121
+ {#if mainConfig}
122
+ <a class="wrap" href="/console/billing">
123
+ <Tooltip position="bottom">
124
+ {#snippet tooltip()}
125
+ {mainConfig.tooltip}
126
+ {/snippet}
127
+ <Tag color={mainConfig.tagColor}>
128
+ {#snippet start()}
129
+ {#if mainConfig.tagIcon}
130
+ <mainConfig.tagIcon size={10} />
131
+ {/if}
132
+ {/snippet}
133
+ {mainConfig.name}
134
+ </Tag>
135
+ </Tooltip>
136
+ </a>
137
+ {/if}
138
+
139
+ {#if mainConfig && complimentaryConfig}
140
+ <span class="pls">+</span>
141
+ {/if}
142
+
143
+ {#if complimentaryConfig}
144
+ <a class="wrap complimentary" href="/console/billing">
145
+ <Tooltip position="bottom">
146
+ {#snippet tooltip()}
147
+ {complimentaryConfig.tooltip}
104
148
  {/snippet}
105
- {config.name}
106
- </Tag>
107
- </Tooltip>
108
- </a>
109
- {/if}
149
+ <Tag color={complimentaryConfig.tagColor}>
150
+ {complimentaryConfig.name}
151
+ </Tag>
152
+ </Tooltip>
153
+ </a>
154
+ {/if}
155
+ </div>
110
156
 
111
157
  <style>
158
+ .outer {
159
+ display: flex;
160
+ align-items: center;
161
+ padding: 0 20px;
162
+ }
163
+
112
164
  .wrap {
113
165
  display: inline-flex;
114
166
  align-items: center;
115
- margin-left: 20px;
167
+ }
168
+
169
+ .pls {
170
+ display: inline-flex;
171
+ margin: 0 6px;
172
+ color: var(--text-light);
173
+ font-size: 12px;
174
+ font-weight: normal;
116
175
  }
117
176
  </style>
@@ -1,5 +1,5 @@
1
1
  export { default as CloudContext } from './CloudContext/CloudContext.svelte';
2
- export { getCloudContext, setCloudContext, type CloudContext as CloudContextType, type CloudContextUser, type CloudContextOrganization, type OrganizationRole, type OrganizationMember, type ResolvedLicense } from './CloudContext/cloudContextState.svelte.js';
2
+ export { getCloudContext, setCloudContext, type CloudContext as CloudContextType, type CloudContextUser, type CloudContextOrganization, type OrganizationRole, type OrganizationMember, type ResolvedLicense, type ResolvedComplimentaryLicense } from './CloudContext/cloudContextState.svelte.js';
3
3
  export { default as HyvorBar } from './HyvorBar/HyvorBar.svelte';
4
4
  export { bar as hyvorBar } from './HyvorBar/bar.js';
5
5
  export { default as ResourceCreator } from './ResourceCreator/ResourceCreator.svelte';
@@ -63,11 +63,12 @@
63
63
  .callout {
64
64
  padding: 15px 25px;
65
65
  border-radius: var(--box-radius);
66
- /* line-height: var(--line-height-content); */
66
+ line-height: var(--line-height-content);
67
67
  }
68
68
 
69
69
  .callout.soft {
70
- background-color: var(--accent-light);
70
+ background-color: var(--gray-light);
71
+ color: var(--gray-dark);
71
72
  }
72
73
 
73
74
  .callout.info {
@@ -94,6 +94,10 @@ content :global(li) {
94
94
  margin-bottom: 8px;
95
95
  }
96
96
 
97
+ content :global(ul) {
98
+ margin-top: 8px;
99
+ }
100
+
97
101
  content :global(.table) {
98
102
  margin: 20px 0;
99
103
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyvor/design",
3
- "version": "2.0.17",
3
+ "version": "2.0.19",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "repository": {