@thatix.io/credit-ui 0.0.1 → 0.0.3

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.
@@ -8861,7 +8861,7 @@ function o5(t) {
8861
8861
  function y0(t) {
8862
8862
  return t.replace(/-([a-z])/g, (e, a) => a.toUpperCase());
8863
8863
  }
8864
- const d5 = "0.0.1";
8864
+ const d5 = "0.0.2";
8865
8865
  export {
8866
8866
  M0 as ActionButton,
8867
8867
  oe as Alert,
package/dist/index.d.ts CHANGED
@@ -13,7 +13,7 @@
13
13
  * import { Button, FormField, LoginForm, FormLayout } from '@thatix.io/credit-ui'
14
14
  * ```
15
15
  */
16
- export declare const version = "0.0.1";
16
+ export declare const version = "0.0.2";
17
17
  export * from './components';
18
18
  export { useTheme } from './composables';
19
19
  export { mergeTheme, generateCSSString, injectThemeCSS, defaultTokens, defaultColors, defaultFonts, } from './themes';
package/dist/nuxt.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";const e=require("@nuxt/kit");var r=typeof document<"u"?document.currentScript:null;const o=e.defineNuxtModule({meta:{name:"@thatix.io/credit-ui",configKey:"creditUi",compatibility:{nuxt:">=3.0.0"}},defaults:{theme:{}},setup(i,s){const t=e.createResolver(typeof document>"u"?require("url").pathToFileURL(__filename).href:r&&r.tagName.toUpperCase()==="SCRIPT"&&r.src||new URL("nuxt.cjs.js",document.baseURI).href);s.options.runtimeConfig.public.creditUi={theme:i.theme||{}},e.addPlugin({src:t.resolve("./runtime/plugin"),mode:"client"}),e.addPlugin({src:t.resolve("./runtime/plugin.server"),mode:"server"}),e.addImports({name:"useTheme",from:t.resolve("./runtime/composables/useTheme")}),s.options.css.push(t.resolve("../themes/tokens.css"))}});module.exports=o;
1
+ "use strict";const e=require("@nuxt/kit");var i=typeof document<"u"?document.currentScript:null;const s=e.defineNuxtModule({meta:{name:"@thatix.io/credit-ui",configKey:"creditUi",compatibility:{nuxt:">=3.0.0"}},defaults:{theme:{}},setup(o,r){const t=e.createResolver(typeof document>"u"?require("url").pathToFileURL(__filename).href:i&&i.tagName.toUpperCase()==="SCRIPT"&&i.src||new URL("nuxt.cjs.js",document.baseURI).href);r.options.runtimeConfig.public.creditUi={theme:o.theme||{}},e.addPlugin({src:t.resolve("./runtime/plugin"),mode:"client"}),e.addPlugin({src:t.resolve("./runtime/plugin.server"),mode:"server"}),e.addImports({name:"useTheme",from:t.resolve("./runtime/composables/useTheme")}),r.options.css.push("@thatix.io/credit-ui/themes/tokens.css")}});module.exports=s;
package/dist/nuxt.es.js CHANGED
@@ -1,5 +1,5 @@
1
- import { defineNuxtModule as r, createResolver as i, addPlugin as o, addImports as m } from "@nuxt/kit";
2
- const l = r({
1
+ import { defineNuxtModule as r, createResolver as s, addPlugin as i, addImports as m } from "@nuxt/kit";
2
+ const n = r({
3
3
  meta: {
4
4
  name: "@thatix.io/credit-ui",
5
5
  configKey: "creditUi",
@@ -10,22 +10,22 @@ const l = r({
10
10
  defaults: {
11
11
  theme: {}
12
12
  },
13
- setup(s, t) {
14
- const e = i(import.meta.url);
13
+ setup(o, t) {
14
+ const e = s(import.meta.url);
15
15
  t.options.runtimeConfig.public.creditUi = {
16
- theme: s.theme || {}
17
- }, o({
16
+ theme: o.theme || {}
17
+ }, i({
18
18
  src: e.resolve("./runtime/plugin"),
19
19
  mode: "client"
20
- }), o({
20
+ }), i({
21
21
  src: e.resolve("./runtime/plugin.server"),
22
22
  mode: "server"
23
23
  }), m({
24
24
  name: "useTheme",
25
25
  from: e.resolve("./runtime/composables/useTheme")
26
- }), t.options.css.push(e.resolve("../themes/tokens.css"));
26
+ }), t.options.css.push("@thatix.io/credit-ui/themes/tokens.css");
27
27
  }
28
28
  });
29
29
  export {
30
- l as default
30
+ n as default
31
31
  };
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Nuxt composable for theme access
3
+ *
4
+ * Provides programmatic access to theme tokens within Nuxt applications.
5
+ * Uses runtimeConfig to access the merged theme configuration.
6
+ *
7
+ * @example
8
+ * ```vue
9
+ * <script setup>
10
+ * const { getColor, getToken, colors, fonts } = useTheme()
11
+ *
12
+ * const primaryColor = getColor('primary')
13
+ * const spacing = getToken('spacing-4')
14
+ * </script>
15
+ * ```
16
+ */
17
+
18
+ import { computed } from 'vue'
19
+ import { useRuntimeConfig } from '#app'
20
+ import { mergeTheme, getCSSVariable } from '@thatix.io/credit-ui/themes'
21
+ import type { ThemeTokens } from '@thatix.io/credit-ui'
22
+
23
+ export function useTheme() {
24
+ const config = useRuntimeConfig()
25
+ const themeConfig = config.public.creditUi?.theme
26
+
27
+ // Merge user config with defaults
28
+ const tokens = computed<ThemeTokens>(() => mergeTheme(themeConfig))
29
+
30
+ // Get color from tokens
31
+ const colors = computed(() => tokens.value.colors)
32
+ const fonts = computed(() => tokens.value.fonts)
33
+
34
+ /**
35
+ * Get a color token value
36
+ * @param name - Color name (e.g., 'primary', 'accent')
37
+ */
38
+ function getColor(name: keyof ThemeTokens['colors']): string {
39
+ return tokens.value.colors[name]
40
+ }
41
+
42
+ /**
43
+ * Get a font family value
44
+ * @param name - Font name ('heading' or 'base')
45
+ */
46
+ function getFont(name: keyof ThemeTokens['fonts']): string {
47
+ return tokens.value.fonts[name]
48
+ }
49
+
50
+ /**
51
+ * Get any CSS variable value from the document
52
+ * @param name - CSS variable name (e.g., '--color-primary', '--spacing-4')
53
+ */
54
+ function getToken(name: string): string {
55
+ // Ensure name starts with --
56
+ const varName = name.startsWith('--') ? name : `--${name}`
57
+ return getCSSVariable(varName)
58
+ }
59
+
60
+ /**
61
+ * Get spacing token value
62
+ * @param size - Spacing size (0, 1, 2, 3, 4, 5, 6, 8, 10, 12, 16)
63
+ */
64
+ function getSpacing(size: keyof ThemeTokens['spacing']): string {
65
+ return tokens.value.spacing[size]
66
+ }
67
+
68
+ /**
69
+ * Get radius token value
70
+ * @param size - Radius size (none, sm, md, lg, xl, 2xl, full)
71
+ */
72
+ function getRadius(size: keyof ThemeTokens['radius']): string {
73
+ return tokens.value.radius[size]
74
+ }
75
+
76
+ return {
77
+ tokens,
78
+ colors,
79
+ fonts,
80
+ getColor,
81
+ getFont,
82
+ getToken,
83
+ getSpacing,
84
+ getRadius,
85
+ }
86
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Server-side Nuxt plugin for theme injection
3
+ *
4
+ * Generates inline CSS for SSR to prevent FOUC (Flash of Unstyled Content).
5
+ * The CSS is injected into the head during server-side rendering.
6
+ */
7
+
8
+ import { defineNuxtPlugin, useRuntimeConfig, useHead } from '#app'
9
+ import { mergeTheme, generateCSSString } from '@thatix.io/credit-ui/themes'
10
+
11
+ export default defineNuxtPlugin({
12
+ name: 'credit-ui-theme-server',
13
+ enforce: 'pre',
14
+ setup() {
15
+ const config = useRuntimeConfig()
16
+ const themeConfig = config.public.creditUi?.theme
17
+
18
+ // Merge user config with defaults
19
+ const tokens = mergeTheme(themeConfig)
20
+ const cssString = generateCSSString(tokens)
21
+
22
+ // Inject CSS into head for SSR
23
+ useHead({
24
+ style: [
25
+ {
26
+ id: 'credit-ui-theme',
27
+ innerHTML: cssString,
28
+ },
29
+ ],
30
+ })
31
+ },
32
+ })
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Client-side Nuxt plugin for theme injection
3
+ *
4
+ * Reads theme config from runtimeConfig and injects CSS variables
5
+ * into the document head, overriding defaults from tokens.css.
6
+ */
7
+
8
+ import { defineNuxtPlugin, useRuntimeConfig } from '#app'
9
+ import { mergeTheme, injectThemeCSS } from '@thatix.io/credit-ui/themes'
10
+
11
+ export default defineNuxtPlugin({
12
+ name: 'credit-ui-theme',
13
+ enforce: 'pre',
14
+ setup() {
15
+ const config = useRuntimeConfig()
16
+ const themeConfig = config.public.creditUi?.theme
17
+
18
+ // Merge user config with defaults and inject CSS
19
+ const tokens = mergeTheme(themeConfig)
20
+ injectThemeCSS(tokens)
21
+ },
22
+ })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thatix.io/credit-ui",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "type": "module",
5
5
  "description": "UI Kit para esteiras de crédito da Thatix",
6
6
  "author": "Thatix.io",
@@ -31,6 +31,9 @@
31
31
  },
32
32
  "./themes/tokens.css": {
33
33
  "style": "./dist/tokens.css"
34
+ },
35
+ "./style.css": {
36
+ "style": "./dist/credit-ui.css"
34
37
  }
35
38
  },
36
39
  "files": [
@@ -17,8 +17,8 @@
17
17
 
18
18
  import { computed } from 'vue'
19
19
  import { useRuntimeConfig } from '#app'
20
- import { mergeTheme, getCSSVariable } from '../../../themes'
21
- import type { ThemeTokens } from '../../../types/theme'
20
+ import { mergeTheme, getCSSVariable } from '@thatix.io/credit-ui/themes'
21
+ import type { ThemeTokens } from '@thatix.io/credit-ui'
22
22
 
23
23
  export function useTheme() {
24
24
  const config = useRuntimeConfig()
@@ -6,7 +6,7 @@
6
6
  */
7
7
 
8
8
  import { defineNuxtPlugin, useRuntimeConfig, useHead } from '#app'
9
- import { mergeTheme, generateCSSString } from '../../themes'
9
+ import { mergeTheme, generateCSSString } from '@thatix.io/credit-ui/themes'
10
10
 
11
11
  export default defineNuxtPlugin({
12
12
  name: 'credit-ui-theme-server',
@@ -6,7 +6,7 @@
6
6
  */
7
7
 
8
8
  import { defineNuxtPlugin, useRuntimeConfig } from '#app'
9
- import { mergeTheme, injectThemeCSS } from '../../themes'
9
+ import { mergeTheme, injectThemeCSS } from '@thatix.io/credit-ui/themes'
10
10
 
11
11
  export default defineNuxtPlugin({
12
12
  name: 'credit-ui-theme',