@resolve-components/theme 1.0.0

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/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@resolve-components/theme",
3
+ "version": "1.0.0",
4
+ "schematics": "./collection.json",
5
+ "description": "🔥 Fully customizable Angular UI components made with ❤️ using Angular CDK 🔥",
6
+ "peerDependencies": {
7
+ "@angular/common": "^21.1.0",
8
+ "@angular/core": "^21.1.0",
9
+ "@angular/forms": "~21.1.0",
10
+ "@angular/cdk": "^21.1.5",
11
+ "rxjs": "~7.8.0",
12
+ "@angular/platform-browser": "~21.1.0",
13
+ "eva-icons": "^1.1.3"
14
+ },
15
+ "keywords": [
16
+ "@resolve-components/theme",
17
+ "@resolve-components",
18
+ "resolve-components",
19
+ "r components",
20
+ "angular components",
21
+ "angular",
22
+ "components",
23
+ "theme",
24
+ "angular theme",
25
+ "ui",
26
+ "ui components",
27
+ "ui library",
28
+ "ui framework"
29
+ ],
30
+ "sideEffects": false,
31
+ "module": "fesm2022/resolve-components-theme.mjs",
32
+ "typings": "types/resolve-components-theme.d.ts",
33
+ "exports": {
34
+ "./package.json": {
35
+ "default": "./package.json"
36
+ },
37
+ ".": {
38
+ "types": "./types/resolve-components-theme.d.ts",
39
+ "default": "./fesm2022/resolve-components-theme.mjs"
40
+ }
41
+ },
42
+ "dependencies": {
43
+ "tslib": "^2.3.0"
44
+ }
45
+ }
@@ -0,0 +1,147 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ngAdd = ngAdd;
4
+ const schematics_1 = require("@angular-devkit/schematics");
5
+ const tasks_1 = require("@angular-devkit/schematics/tasks");
6
+ function getWorkspace(tree) {
7
+ const file = tree.exists('angular.json')
8
+ ? 'angular.json'
9
+ : tree.exists('workspace.json')
10
+ ? 'workspace.json'
11
+ : null;
12
+ if (!file)
13
+ return null;
14
+ try {
15
+ const content = JSON.parse(tree.read(file).toString('utf-8'));
16
+ return { file, content };
17
+ }
18
+ catch {
19
+ return null;
20
+ }
21
+ }
22
+ function resolveProjectName(ws, options) {
23
+ if (options.project)
24
+ return options.project;
25
+ const c = ws.content;
26
+ return c['defaultProject'] ?? Object.keys(c['projects'] ?? {})[0] ?? null;
27
+ }
28
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
+ function getBuildOptions(project) {
30
+ return (project?.['architect']?.['build']?.['options'] ??
31
+ project?.['targets']?.['build']?.['options'] ??
32
+ null);
33
+ }
34
+ // ---------------------------------------------------------------------------
35
+ // Rule: patch angular.json
36
+ // ---------------------------------------------------------------------------
37
+ function addAngularJsonConfig(options) {
38
+ return (tree) => {
39
+ const ws = getWorkspace(tree);
40
+ if (!ws)
41
+ return tree;
42
+ const projectName = resolveProjectName(ws, options);
43
+ if (!projectName)
44
+ return tree;
45
+ const project = ws.content['projects']?.[projectName];
46
+ if (!project)
47
+ return tree;
48
+ const buildOptions = getBuildOptions(project);
49
+ if (!buildOptions)
50
+ return tree;
51
+ // ── styles: prepend CDK overlay CSS ──
52
+ const cdkStyle = 'node_modules/@angular/cdk/overlay-prebuilt.css';
53
+ if (!Array.isArray(buildOptions['styles'])) {
54
+ buildOptions['styles'] = [];
55
+ }
56
+ if (!buildOptions['styles'].includes(cdkStyle)) {
57
+ buildOptions['styles'].unshift(cdkStyle);
58
+ }
59
+ // ── stylePreprocessorOptions: add includePath ──
60
+ const includePath = 'node_modules/@resolve-components/theme/styles';
61
+ buildOptions['stylePreprocessorOptions'] ??= {};
62
+ const paths = (buildOptions['stylePreprocessorOptions']['includePaths'] ??= []);
63
+ if (!paths.includes(includePath)) {
64
+ paths.unshift(includePath);
65
+ }
66
+ tree.overwrite(ws.file, JSON.stringify(ws.content, null, 2));
67
+ return tree;
68
+ };
69
+ }
70
+ // ---------------------------------------------------------------------------
71
+ // Rule: add provideRcTheme() to app.config.ts
72
+ // ---------------------------------------------------------------------------
73
+ function addProviderToConfig() {
74
+ return (tree) => {
75
+ const configPath = 'src/app/app.config.ts';
76
+ if (!tree.exists(configPath))
77
+ return tree;
78
+ let content = tree.read(configPath).toString('utf-8');
79
+ if (content.includes('provideRcTheme'))
80
+ return tree;
81
+ // Insert import after the last existing @angular import
82
+ const importLine = `import { provideRcTheme } from '@resolve-components/theme';\n`;
83
+ const lastAngularImportMatch = [...content.matchAll(/^import .*;\n/gm)].pop();
84
+ if (lastAngularImportMatch) {
85
+ const insertAt = lastAngularImportMatch.index + lastAngularImportMatch[0].length;
86
+ content = content.slice(0, insertAt) + importLine + content.slice(insertAt);
87
+ }
88
+ else {
89
+ content = importLine + content;
90
+ }
91
+ // Insert provider at start of providers array
92
+ content = content.replace(/(providers:\s*\[)/, `$1\n provideRcTheme({ name: 'default' }),`);
93
+ tree.overwrite(configPath, content);
94
+ return tree;
95
+ };
96
+ }
97
+ // ---------------------------------------------------------------------------
98
+ // Rule: prepend @use / @include to styles.scss
99
+ // ---------------------------------------------------------------------------
100
+ function addGlobalStyles() {
101
+ return (tree) => {
102
+ const stylesPath = 'src/styles.scss';
103
+ if (!tree.exists(stylesPath))
104
+ return tree;
105
+ let content = tree.read(stylesPath).toString('utf-8');
106
+ if (content.includes('@resolve-components/theme') || content.includes(`@use 'all'`)) {
107
+ return tree;
108
+ }
109
+ const addition = [
110
+ `@use 'all';`,
111
+ `@use 'theming/install' as *;`,
112
+ ``,
113
+ `@include rc-install() {`,
114
+ ` *,`,
115
+ ` *::before,`,
116
+ ` *::after { box-sizing: border-box; }`,
117
+ ``,
118
+ ` body {`,
119
+ ` margin: 0;`,
120
+ ` font-family: rc-theme('font-family-primary');`,
121
+ ` font-size: rc-theme('text-body-font-size');`,
122
+ ` color: rc-theme('text-basic-color');`,
123
+ ` background-color: rc-theme('background-basic-color-1');`,
124
+ ` }`,
125
+ `}`,
126
+ ``,
127
+ ].join('\n');
128
+ tree.overwrite(stylesPath, addition + content);
129
+ return tree;
130
+ };
131
+ }
132
+ // ---------------------------------------------------------------------------
133
+ // Exported schematic factory
134
+ // ---------------------------------------------------------------------------
135
+ function ngAdd(options) {
136
+ return (tree, context) => {
137
+ context.logger.info('Installing @resolve-components/theme…');
138
+ return (0, schematics_1.chain)([
139
+ addAngularJsonConfig(options),
140
+ addProviderToConfig(),
141
+ addGlobalStyles(),
142
+ (_tree, ctx) => {
143
+ ctx.addTask(new tasks_1.NodePackageInstallTask());
144
+ },
145
+ ])(tree, context);
146
+ };
147
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema",
3
+ "id": "SchematicsResolveComponentsNgAdd",
4
+ "title": "Add @resolve-components/theme to an Angular project",
5
+ "type": "object",
6
+ "properties": {
7
+ "project": {
8
+ "type": "string",
9
+ "description": "The name of the Angular project to configure. Defaults to the default project.",
10
+ "$default": {
11
+ "$source": "projectName"
12
+ }
13
+ }
14
+ }
15
+ }
@@ -0,0 +1,52 @@
1
+ // =============================================================================
2
+ // Resolve Components — Styles Entry Point
3
+ // =============================================================================
4
+ // This is the main entry point for the entire SCSS theming system.
5
+ //
6
+ // Usage in consumer app's styles.scss:
7
+ //
8
+ // @use '@resolve-components/styles' as *;
9
+ //
10
+ // @include rc-install() {
11
+ // // optional global overrides
12
+ // }
13
+ //
14
+ // Or import individual parts:
15
+ //
16
+ // @use '@resolve-components/styles/theming' as *;
17
+ // @use '@resolve-components/styles/themes';
18
+ //
19
+ // =============================================================================
20
+
21
+ @forward 'theming';
22
+ @forward 'themes';
23
+ @forward 'globals';
24
+
25
+ @use '../button/rc-button';
26
+ @use '../icon/rc-icon';
27
+ @use '../tabs/rc-tabs';
28
+ @use '../alert/rc-alert';
29
+ @use '../toast/rc-toast';
30
+ @use '../dialog/rc-dialog';
31
+ @use '../input/rc-input';
32
+ @use '../table/rc-table';
33
+ @use '../chip/rc-chip';
34
+ @use '../radio/rc-radio';
35
+ @use '../toggle/rc-toggle';
36
+ @use '../checkbox/rc-checkbox';
37
+ @use '../select/rc-select';
38
+ @use '../accordion/rc-accordion';
39
+ @use '../slider/rc-slider';
40
+ @use '../autocomplete/rc-autocomplete';
41
+ @use '../sidenav/rc-sidenav';
42
+ @use '../navbar/rc-navbar';
43
+ @use '../datepicker/rc-datepicker';
44
+ @use '../tree/rc-tree';
45
+ @use '../spinner/rc-spinner';
46
+ @use '../progress-bar/rc-progress-bar';
47
+ @use '../file-upload/rc-file-upload';
48
+ @use '../virtual-scroll/rc-virtual-scroll';
49
+ @use '../tooltip/rc-tooltip';
50
+ @use '../menu/rc-menu';
51
+ @use '../infinite-scroll/rc-infinite-scroll';
52
+ @use '../paginator/rc-paginator';
@@ -0,0 +1,66 @@
1
+ // =============================================================================
2
+ // Resolve Components — Global Reset & Base Styles
3
+ // =============================================================================
4
+ // Lightweight normalizations applied once per theme installation.
5
+ // Components should NOT depend on these — they are quality-of-life defaults.
6
+ // =============================================================================
7
+
8
+ @use 'theming/get-value' as *;
9
+
10
+ *,
11
+ *::before,
12
+ *::after {
13
+ box-sizing: border-box;
14
+ }
15
+
16
+ body {
17
+ margin: 0;
18
+ padding: 0;
19
+ font-family: rc-theme('font-family-primary');
20
+ font-size: rc-theme('text-body-font-size');
21
+ color: rc-theme('text-basic-color');
22
+ background-color: rc-theme('background-basic-color-1');
23
+ -webkit-font-smoothing: antialiased;
24
+ -moz-osx-font-smoothing: grayscale;
25
+ }
26
+
27
+ a {
28
+ color: rc-theme('color-primary-default');
29
+ text-decoration: none;
30
+ }
31
+
32
+ h1,
33
+ h2,
34
+ h3,
35
+ h4,
36
+ h5,
37
+ h6 {
38
+ margin-top: 0;
39
+ font-family: rc-theme('font-family-primary');
40
+ color: rc-theme('text-basic-color');
41
+ }
42
+
43
+ h1 {
44
+ font-size: rc-theme('text-heading-1-font-size');
45
+ font-weight: rc-theme('text-heading-1-font-weight');
46
+ }
47
+
48
+ h2 {
49
+ font-size: rc-theme('text-heading-2-font-size');
50
+ font-weight: rc-theme('text-heading-2-font-weight');
51
+ }
52
+
53
+ h3 {
54
+ font-size: rc-theme('text-heading-3-font-size');
55
+ font-weight: rc-theme('text-heading-3-font-weight');
56
+ }
57
+
58
+ h4 {
59
+ font-size: rc-theme('text-heading-4-font-size');
60
+ font-weight: rc-theme('text-heading-4-font-weight');
61
+ }
62
+
63
+ code,
64
+ pre {
65
+ font-family: rc-theme('font-family-mono');
66
+ }
@@ -0,0 +1,9 @@
1
+ // =============================================================================
2
+ // Resolve Components — Themes Entry Point
3
+ // =============================================================================
4
+ // Import this file to register all built-in themes.
5
+ // Order matters: default must be registered before any child themes.
6
+ // =============================================================================
7
+
8
+ @use 'themes/default';
9
+ @use 'themes/dark';
@@ -0,0 +1,20 @@
1
+ // =============================================================================
2
+ // Resolve Components — Theming (Public Entry Point)
3
+ // =============================================================================
4
+ // This file forwards the entire theming API for consumers.
5
+ //
6
+ // Usage:
7
+ // @use '@resolve-components/styles/theming' as *;
8
+ //
9
+ // .my-component {
10
+ // color: rc-theme('text-basic-color');
11
+ // }
12
+ // =============================================================================
13
+
14
+ @forward 'theming/theming-variables';
15
+ @forward 'theming/functions';
16
+ @forward 'theming/mapping';
17
+ @forward 'theming/register';
18
+ @forward 'theming/get-value';
19
+ @forward 'theming/install';
20
+ @forward 'theming/animation';
@@ -0,0 +1,107 @@
1
+ // =============================================================================
2
+ // Resolve Components — Dark Theme
3
+ // =============================================================================
4
+ // Inherits from default. Only overrides what changes for dark mode.
5
+ // Follows Microsoft Fluent dark surface / text conventions.
6
+ // =============================================================================
7
+
8
+ @use 'sass:string';
9
+ @use 'default'; // Ensure default is registered first
10
+ @use '../theming/theming-variables' as vars;
11
+ @use '../theming/register' as reg;
12
+
13
+ $theme: (
14
+ // Direct CSS properties (emitted without -- prefix)
15
+ _color-scheme: dark,
16
+
17
+ // ── Adjusted Primary for dark backgrounds ─────────────────────────────
18
+ color-primary-default: color-primary-400,
19
+ color-primary-hover: color-primary-300,
20
+ color-primary-active: color-primary-200,
21
+ color-primary-focus: color-primary-400,
22
+ color-primary-transparent-default: rgba(91, 163, 230, 0.1),
23
+ color-primary-transparent-hover: rgba(91, 163, 230, 0.16),
24
+ color-primary-transparent-active: rgba(91, 163, 230, 0.22),
25
+ // ── Adjusted Success ──────────────────────────────────────────────────
26
+ color-success-default: color-success-400,
27
+ color-success-hover: color-success-300,
28
+ color-success-active: color-success-200,
29
+
30
+ // ── Adjusted Warning ──────────────────────────────────────────────────
31
+ color-warning-default: color-warning-400,
32
+ color-warning-hover: color-warning-300,
33
+ color-warning-active: color-warning-200,
34
+
35
+ // ── Adjusted Danger ───────────────────────────────────────────────────
36
+ color-danger-default: color-danger-400,
37
+ color-danger-hover: color-danger-300,
38
+ color-danger-active: color-danger-200,
39
+
40
+ // ── Adjusted Info ─────────────────────────────────────────────────────
41
+ color-info-default: color-info-400,
42
+ color-info-hover: color-info-300,
43
+ color-info-active: color-info-200,
44
+
45
+ // ── Dark Backgrounds ──────────────────────────────────────────────────
46
+ background-basic-color-1: color-basic-1000,
47
+ background-basic-color-2: color-basic-900,
48
+ background-basic-color-3: color-basic-800,
49
+ background-basic-color-4: color-basic-700,
50
+ background-alternative-color-1: color-basic-100,
51
+ background-alternative-color-2: color-basic-200,
52
+
53
+ // ── Text on dark ──────────────────────────────────────────────────────
54
+ text-basic-color: color-basic-200,
55
+ text-alternate-color: color-basic-1000,
56
+ text-hint-color: color-basic-500,
57
+ text-disabled-color: color-basic-700,
58
+
59
+ // ── Borders on dark ───────────────────────────────────────────────────
60
+ border-basic-color: color-basic-800,
61
+ border-basic-color-2: color-basic-700,
62
+ border-basic-color-3: color-basic-900,
63
+
64
+ // ── Shadows on dark ───────────────────────────────────────────────────
65
+ shadow: string.unquote(
66
+ '0 1.6px 3.6px 0 rgba(0, 0, 0, 0.38), 0 0.3px 0.9px 0 rgba(0, 0, 0, 0.30)'
67
+ ),
68
+ shadow-sm: string.unquote(
69
+ '0 0.8px 1.8px 0 rgba(0, 0, 0, 0.30), 0 0.15px 0.45px 0 rgba(0, 0, 0, 0.24)'
70
+ ),
71
+ shadow-md: string.unquote(
72
+ '0 3.2px 7.2px 0 rgba(0, 0, 0, 0.38), 0 0.6px 1.8px 0 rgba(0, 0, 0, 0.30)'
73
+ ),
74
+ shadow-lg: string.unquote(
75
+ '0 6.4px 14.4px 0 rgba(0, 0, 0, 0.38), 0 1.2px 3.6px 0 rgba(0, 0, 0, 0.30)'
76
+ ),
77
+ // ── Outline / Focus ───────────────────────────────────────────────────
78
+ outline-color: color-basic-100,
79
+
80
+ // ── Divider ───────────────────────────────────────────────────────────
81
+ divider-color: border-basic-color,
82
+
83
+ // ── Alert (dark overrides) ────────────────────────────────────────────
84
+ alert-info-subtle-background: rgba(0, 183, 195, 0.12),
85
+ alert-info-subtle-color: color-info-300,
86
+ alert-info-subtle-border: rgba(0, 183, 195, 0.3),
87
+ alert-info-outline-color: color-info-300,
88
+ alert-success-subtle-background: rgba(16, 124, 16, 0.14),
89
+ alert-success-subtle-color: color-success-300,
90
+ alert-success-subtle-border: rgba(84, 176, 84, 0.35),
91
+ alert-success-outline-color: color-success-300,
92
+ alert-warning-subtle-background: rgba(255, 185, 0, 0.12),
93
+ alert-warning-subtle-color: color-warning-300,
94
+ alert-warning-subtle-border: rgba(255, 185, 0, 0.3),
95
+ alert-warning-outline-color: color-warning-300,
96
+ alert-danger-subtle-background: rgba(209, 52, 56, 0.14),
97
+ alert-danger-subtle-color: color-danger-300,
98
+ alert-danger-subtle-border: rgba(231, 72, 86, 0.35),
99
+ alert-danger-outline-color: color-danger-300,
100
+
101
+ // ── Toast (dark overrides) ────────────────────────────────────────────
102
+ toast-background: background-basic-color-2,
103
+ toast-border-color: border-basic-color-2
104
+ );
105
+
106
+ // Register dark theme with 'default' as parent
107
+ vars.$rc-themes: reg.rc-register-theme($theme, dark, default);