Skip to content

Commit 08a75e4

Browse files
committed
feat: add spartan basic components
1 parent 5bbfc71 commit 08a75e4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1725
-331
lines changed

.storybook/preview.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
// import "../src/styles.css";
1+
// import '../src/styles.css';

libs/ui/ui-button-helm/.eslintrc.json

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"extends": [
3+
"../../../.eslintrc.base.json"
4+
],
5+
"ignorePatterns": [
6+
"!**/*"
7+
],
8+
"overrides": [
9+
{
10+
"files": [
11+
"*.ts"
12+
],
13+
"extends": [
14+
"plugin:@nx/angular",
15+
"plugin:@angular-eslint/template/process-inline-templates"
16+
],
17+
"rules": {
18+
"@angular-eslint/directive-selector": [
19+
"error",
20+
{
21+
"type": "attribute",
22+
"prefix": "hlm",
23+
"style": "camelCase"
24+
}
25+
],
26+
"@angular-eslint/component-selector": [
27+
"error",
28+
{
29+
"type": "element",
30+
"prefix": "hlm",
31+
"style": "kebab-case"
32+
}
33+
]
34+
}
35+
},
36+
{
37+
"files": [
38+
"*.html"
39+
],
40+
"extends": [
41+
"plugin:@nx/angular-template"
42+
],
43+
"rules": {}
44+
},
45+
{
46+
"files": [
47+
"*.json"
48+
],
49+
"parser": "jsonc-eslint-parser",
50+
"rules": {
51+
"@nx/dependency-checks": "error"
52+
}
53+
}
54+
]
55+
}

libs/ui/ui-button-helm/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# ui-button-helm
2+
3+
This library was generated with [Nx](https://nx.dev).
4+
5+
6+
## Running unit tests
7+
8+
Run `nx test ui-button-helm` to execute the unit tests.
9+

libs/ui/ui-button-helm/jest.config.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* eslint-disable */
2+
export default {
3+
displayName: 'ui-button-helm',
4+
preset: '../../../jest.preset.js',
5+
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
6+
coverageDirectory: '../../../coverage/libs/ui/ui-button-helm',
7+
transform: {
8+
'^.+\\.(ts|mjs|js|html)$': [
9+
'jest-preset-angular',
10+
{
11+
tsconfig: '<rootDir>/tsconfig.spec.json',
12+
stringifyContentPathRegex: '\\.(html|svg)$',
13+
},
14+
],
15+
},
16+
transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'],
17+
snapshotSerializers: [
18+
'jest-preset-angular/build/serializers/no-ng-attributes',
19+
'jest-preset-angular/build/serializers/ng-snapshot',
20+
'jest-preset-angular/build/serializers/html-comment',
21+
]
22+
};
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"$schema": "../../../node_modules/ng-packagr/ng-package.schema.json",
3+
"dest": "../../../dist/libs/ui/ui-button-helm",
4+
"lib": {
5+
"entryFile": "src/index.ts"
6+
}
7+
}

libs/ui/ui-button-helm/package.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "@spartan-ng/ui-button-helm",
3+
"version": "0.0.1",
4+
"peerDependencies": {
5+
"@angular/common": "^18.0.0",
6+
"@angular/core": "^18.0.0"
7+
},
8+
"sideEffects": false
9+
}

libs/ui/ui-button-helm/project.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"name": "ui-button-helm",
3+
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
4+
"sourceRoot": "libs/ui/ui-button-helm/src",
5+
"prefix": "hlm",
6+
"projectType": "library",
7+
"tags": [],
8+
"targets": {
9+
"build": {
10+
"executor": "@nx/angular:ng-packagr-lite",
11+
"outputs": [
12+
"{workspaceRoot}/dist/{projectRoot}"
13+
],
14+
"options": {
15+
"project": "libs/ui/ui-button-helm/ng-package.json"
16+
},
17+
"configurations": {
18+
"production": {
19+
"tsConfig": "libs/ui/ui-button-helm/tsconfig.lib.prod.json"
20+
},
21+
"development": {
22+
"tsConfig": "libs/ui/ui-button-helm/tsconfig.lib.json"
23+
}
24+
},
25+
"defaultConfiguration": "production"
26+
},
27+
"test": {
28+
"executor": "@nx/jest:jest",
29+
"outputs": [
30+
"{workspaceRoot}/coverage/{projectRoot}"
31+
],
32+
"options": {
33+
"jestConfig": "libs/ui/ui-button-helm/jest.config.ts"
34+
}
35+
},
36+
"lint": {
37+
"executor": "@nx/eslint:lint"
38+
}
39+
}
40+
}

libs/ui/ui-button-helm/src/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { NgModule } from '@angular/core';
2+
import { HlmButtonDirective } from './lib/hlm-button.directive';
3+
4+
export * from './lib/hlm-button.directive';
5+
6+
@NgModule({
7+
imports: [HlmButtonDirective],
8+
exports: [HlmButtonDirective],
9+
})
10+
export class HlmButtonModule {}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import { computed, Directive, Input, input, signal } from '@angular/core';
2+
import { hlm } from '@spartan-ng/ui-core';
3+
import { cva, type VariantProps } from 'class-variance-authority';
4+
import type { ClassValue } from 'clsx';
5+
6+
export const buttonVariants = cva(
7+
'inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:opacity-50 disabled:pointer-events-none ring-offset-background',
8+
{
9+
variants: {
10+
variant: {
11+
default: 'bg-primary text-primary-foreground hover:bg-primary/90',
12+
destructive:
13+
'bg-destructive text-destructive-foreground hover:bg-destructive/90',
14+
outline:
15+
'border border-input hover:bg-accent hover:text-accent-foreground',
16+
secondary:
17+
'bg-secondary text-secondary-foreground hover:bg-secondary/80',
18+
ghost: 'hover:bg-accent hover:text-accent-foreground',
19+
link: 'underline-offset-4 hover:underline text-primary',
20+
},
21+
size: {
22+
xs: 'h-8 p-1 rounded-md text-xs',
23+
default: 'h-10 py-2 px-4',
24+
sm: 'h-9 px-3 rounded-md',
25+
lg: 'h-11 px-8 rounded-md',
26+
icon: 'h-10 w-10',
27+
},
28+
},
29+
defaultVariants: {
30+
variant: 'default',
31+
size: 'default',
32+
},
33+
}
34+
);
35+
export type ButtonVariants = VariantProps<typeof buttonVariants>;
36+
37+
@Directive({
38+
selector: '[hlmBtn]',
39+
standalone: true,
40+
host: {
41+
'[class]': '_computedClass()',
42+
},
43+
})
44+
export class HlmButtonDirective {
45+
public readonly userClass = input<ClassValue>('', { alias: 'class' });
46+
private readonly _settableClass = signal<ClassValue>('');
47+
48+
protected _computedClass = computed(() =>
49+
hlm(
50+
buttonVariants({ variant: this._variant(), size: this._size() }),
51+
this._settableClass(),
52+
this.userClass()
53+
)
54+
);
55+
56+
setClass(value: ClassValue) {
57+
this._settableClass.set(value);
58+
}
59+
60+
private readonly _variant = signal<ButtonVariants['variant']>('default');
61+
@Input()
62+
set variant(variant: ButtonVariants['variant']) {
63+
this._variant.set(variant);
64+
}
65+
66+
private readonly _size = signal<ButtonVariants['size']>('default');
67+
@Input()
68+
set size(size: ButtonVariants['size']) {
69+
this._size.set(size);
70+
}
71+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import 'jest-preset-angular/setup-jest';

libs/ui/ui-button-helm/tsconfig.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es2022",
4+
"useDefineForClassFields": false
5+
},
6+
"files": [],
7+
"include": [],
8+
"references": [
9+
{
10+
"path": "./tsconfig.lib.json"
11+
},
12+
{
13+
"path": "./tsconfig.spec.json"
14+
}
15+
],
16+
"extends": "../../../tsconfig.base.json"
17+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "../../../dist/out-tsc",
5+
"declaration": true,
6+
"declarationMap": true,
7+
"inlineSources": true,
8+
"types": []
9+
},
10+
"exclude": [
11+
"src/**/*.spec.ts",
12+
"src/test-setup.ts",
13+
"jest.config.ts",
14+
"src/**/*.test.ts"
15+
],
16+
"include": [
17+
"src/**/*.ts"
18+
]
19+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "./tsconfig.lib.json",
3+
"compilerOptions": {
4+
"declarationMap": false
5+
},
6+
"angularCompilerOptions": {}
7+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "../../../dist/out-tsc",
5+
"module": "commonjs",
6+
"target": "es2016",
7+
"types": ["jest", "node"]
8+
},
9+
"files": ["src/test-setup.ts"],
10+
"include": [
11+
"jest.config.ts",
12+
"src/**/*.test.ts",
13+
"src/**/*.spec.ts",
14+
"src/**/*.d.ts"
15+
]
16+
}

libs/ui/ui-card-helm/.eslintrc.json

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"extends": [
3+
"../../../.eslintrc.base.json"
4+
],
5+
"ignorePatterns": [
6+
"!**/*"
7+
],
8+
"overrides": [
9+
{
10+
"files": [
11+
"*.ts"
12+
],
13+
"extends": [
14+
"plugin:@nx/angular",
15+
"plugin:@angular-eslint/template/process-inline-templates"
16+
],
17+
"rules": {
18+
"@angular-eslint/directive-selector": [
19+
"error",
20+
{
21+
"type": "attribute",
22+
"prefix": "hlm",
23+
"style": "camelCase"
24+
}
25+
],
26+
"@angular-eslint/component-selector": [
27+
"error",
28+
{
29+
"type": "element",
30+
"prefix": "hlm",
31+
"style": "kebab-case"
32+
}
33+
]
34+
}
35+
},
36+
{
37+
"files": [
38+
"*.html"
39+
],
40+
"extends": [
41+
"plugin:@nx/angular-template"
42+
],
43+
"rules": {}
44+
},
45+
{
46+
"files": [
47+
"*.json"
48+
],
49+
"parser": "jsonc-eslint-parser",
50+
"rules": {
51+
"@nx/dependency-checks": "error"
52+
}
53+
}
54+
]
55+
}

libs/ui/ui-card-helm/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# ui-card-helm
2+
3+
This library was generated with [Nx](https://nx.dev).
4+
5+
6+
## Running unit tests
7+
8+
Run `nx test ui-card-helm` to execute the unit tests.
9+

libs/ui/ui-card-helm/jest.config.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* eslint-disable */
2+
export default {
3+
displayName: 'ui-card-helm',
4+
preset: '../../../jest.preset.js',
5+
setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
6+
coverageDirectory: '../../../coverage/libs/ui/ui-card-helm',
7+
transform: {
8+
'^.+\\.(ts|mjs|js|html)$': [
9+
'jest-preset-angular',
10+
{
11+
tsconfig: '<rootDir>/tsconfig.spec.json',
12+
stringifyContentPathRegex: '\\.(html|svg)$',
13+
},
14+
],
15+
},
16+
transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'],
17+
snapshotSerializers: [
18+
'jest-preset-angular/build/serializers/no-ng-attributes',
19+
'jest-preset-angular/build/serializers/ng-snapshot',
20+
'jest-preset-angular/build/serializers/html-comment',
21+
]
22+
};

libs/ui/ui-card-helm/ng-package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"$schema": "../../../node_modules/ng-packagr/ng-package.schema.json",
3+
"dest": "../../../dist/libs/ui/ui-card-helm",
4+
"lib": {
5+
"entryFile": "src/index.ts"
6+
}
7+
}

0 commit comments

Comments
 (0)