Skip to content

Commit 73675c9

Browse files
committed
init
1 parent a9ff649 commit 73675c9

File tree

70 files changed

+121712
-28706
lines changed

Some content is hidden

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

70 files changed

+121712
-28706
lines changed

.github/workflows/deploy-pages.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: GitHub Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
# Allows you to run this workflow manually from the Actions tab
8+
workflow_dispatch:
9+
10+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
11+
permissions:
12+
contents: read
13+
pages: write
14+
id-token: write
15+
16+
jobs:
17+
deploy:
18+
runs-on: ubuntu-latest
19+
environment:
20+
name: github-pages
21+
url: ${{ steps.deployment.outputs.page_url }}
22+
steps:
23+
- name: Checkout 🛎️
24+
uses: actions/checkout@v4
25+
26+
- name: Setup Node version 🍀
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version: '20'
30+
cache: 'npm'
31+
32+
- name: Install dependencies 📦
33+
run: npm ci
34+
35+
- name: Configure GitHub Pages ⚙️
36+
uses: actions/configure-pages@v5
37+
38+
- name: Build Storybook 🛠️
39+
run: |
40+
npm run build:storybook
41+
env:
42+
PUBLIC_URL: "/${{ github.event.repository.name }}/"
43+
44+
- name: Upload artifacts 📁
45+
uses: actions/upload-pages-artifact@v3
46+
with:
47+
path: storybook-static
48+
49+
- name: Deploy to GitHub Pages 🚀
50+
id: deployment
51+
uses: actions/deploy-pages@v4

.storybook/main.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import type { StorybookConfig } from '@storybook/angular';
2+
3+
const config: StorybookConfig = {
4+
stories: ['../src-storybook/**/*.mdx', '../src-storybook/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
5+
addons: ['@storybook/addon-docs'],
6+
framework: {
7+
name: '@storybook/angular',
8+
options: {},
9+
},
10+
staticDirs: [{ from: '../src-storybook/assets', to: '/assets' }],
11+
};
12+
export default config;

.storybook/preview.ts

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import { applicationConfig, Preview } from '@storybook/angular';
2+
import { setCompodocJson } from '@storybook/addon-docs/angular';
3+
4+
import docJson from '../documentation.json';
5+
6+
import '!style-loader!css-loader!postcss-loader!sass-loader!../src/styles.scss';
7+
8+
import { provideAnimations } from '@angular/platform-browser/animations';
9+
10+
setCompodocJson(docJson);
11+
12+
const THEMES = {
13+
'ek5-light-primary': 'assets/themes/ek5-light-primary/theme.css',
14+
'ek5-dark-primary': 'assets/themes/ek5-dark-primary/theme.css',
15+
'ek5-light-secondary': 'assets/themes/ek5-light-secondary/theme.css',
16+
'ek5-dark-secondary': 'assets/themes/ek5-dark-secondary/theme.css',
17+
'brand-light-primary': 'assets/themes/brand-light-primary/theme.css',
18+
'brand-dark-primary': 'assets/themes/brand-dark-primary/theme.css',
19+
'brand-light-secondary': 'assets/themes/brand-light-secondary/theme.css',
20+
'brand-dark-secondary': 'assets/themes/brand-dark-secondary/theme.css',
21+
};
22+
23+
// функция переключения темы
24+
function setTheme(theme: keyof typeof THEMES) {
25+
const id = 'storybook-theme';
26+
let linkTag = document.getElementById(id) as HTMLLinkElement | null;
27+
28+
if (!linkTag) {
29+
linkTag = document.createElement('link');
30+
linkTag.id = id;
31+
linkTag.rel = 'stylesheet';
32+
document.head.appendChild(linkTag);
33+
}
34+
35+
linkTag.href = THEMES[theme];
36+
}
37+
38+
const preview: Preview = {
39+
decorators: [
40+
applicationConfig({
41+
providers: [provideAnimations()],
42+
}),
43+
(storyFn, context) => {
44+
const theme = context.globals?.['theme'] || 'ek5-light-primary';
45+
46+
// Логика подмены <link>
47+
setTheme(theme as keyof typeof THEMES);
48+
49+
return storyFn();
50+
},
51+
],
52+
parameters: {
53+
controls: {
54+
matchers: {
55+
color: /(background|color)$/i,
56+
date: /Date$/i,
57+
},
58+
},
59+
},
60+
globalTypes: {
61+
theme: {
62+
name: 'Theme',
63+
description: 'Global theme for components',
64+
defaultValue: 'ek5-light-primary',
65+
toolbar: {
66+
icon: 'paintbrush',
67+
dynamicTitle: true,
68+
items: [
69+
{ value: 'ek5-light-primary', title: 'ek5-light-primary' },
70+
{ value: 'ek5-dark-primary', title: 'ek5-dark-primary' },
71+
{ value: 'ek5-light-secondary', title: 'ek5-light-secondary' },
72+
{ value: 'ek5-dark-secondary', title: 'ek5-dark-secondary' },
73+
{ value: 'brand-light-primary', title: 'brand-light-primary' },
74+
{ value: 'brand-dark-primary', title: 'brand-dark-primary' },
75+
{ value: 'brand-light-secondary', title: 'brand-light-secondary' },
76+
{ value: 'brand-dark-secondary', title: 'brand-dark-secondary' },
77+
],
78+
},
79+
},
80+
},
81+
};
82+
83+
export default preview;

.storybook/tsconfig.doc.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// This tsconfig is used by Compodoc to generate the documentation for the project.
2+
// If Compodoc is not used, this file can be deleted.
3+
{
4+
"extends": "./tsconfig.json",
5+
// Exclude all files that are not needed for documentation generation.
6+
"exclude": ["../src-storybook/test.ts", "../src-storybook/**/*.spec.ts", "../src-storybook/**/*.stories.ts"],
7+
// Please make sure to include all files from which Compodoc should generate documentation.
8+
"include": ["../src-storybook/**/*"],
9+
"files": ["./typings.d.ts"]
10+
}

.storybook/tsconfig.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"extends": "../tsconfig.storybook-app.json",
3+
"compilerOptions": {
4+
"types": ["node"],
5+
"allowSyntheticDefaultImports": true,
6+
"resolveJsonModule": true
7+
},
8+
"exclude": ["../src-storybook/test.ts", "../src-storybook/**/*.spec.ts"],
9+
"include": ["../src-storybook/**/*.stories.*", "./preview.ts"],
10+
"files": ["./typings.d.ts"]
11+
}

.storybook/typings.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
declare module '*.md' {
2+
const content: string;
3+
export default content;
4+
}

angular.json

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,140 @@
124124
"builder": "./builder:build-styles"
125125
}
126126
}
127+
},
128+
"ng-storybook": {
129+
"projectType": "application",
130+
"schematics": {
131+
"@schematics/angular:component": {
132+
"style": "scss"
133+
}
134+
},
135+
"root": "",
136+
"sourceRoot": "src-storybook",
137+
"prefix": "app",
138+
"architect": {
139+
"build": {
140+
"builder": "@angular-devkit/build-angular:application",
141+
"options": {
142+
"outputPath": "dist/ng-storybook",
143+
"index": "src-storybook/index.html",
144+
"browser": "src-storybook/main.ts",
145+
"polyfills": [
146+
"zone.js"
147+
],
148+
"tsConfig": "tsconfig.storybook-app.json",
149+
"inlineStyleLanguage": "scss",
150+
"assets": [
151+
{
152+
"glob": "**/*",
153+
"input": "public"
154+
}
155+
],
156+
"styles": [
157+
"src-storybook/styles.scss"
158+
],
159+
"scripts": []
160+
},
161+
"configurations": {
162+
"production": {
163+
"budgets": [
164+
{
165+
"type": "initial",
166+
"maximumWarning": "500kB",
167+
"maximumError": "1MB"
168+
},
169+
{
170+
"type": "anyComponentStyle",
171+
"maximumWarning": "2kB",
172+
"maximumError": "4kB"
173+
}
174+
],
175+
"outputHashing": "all"
176+
},
177+
"development": {
178+
"optimization": false,
179+
"extractLicenses": false,
180+
"sourceMap": true
181+
}
182+
},
183+
"defaultConfiguration": "production"
184+
},
185+
"serve": {
186+
"builder": "@angular-devkit/build-angular:dev-server",
187+
"configurations": {
188+
"production": {
189+
"buildTarget": "ng-storybook:build:production"
190+
},
191+
"development": {
192+
"buildTarget": "ng-storybook:build:development"
193+
}
194+
},
195+
"defaultConfiguration": "development"
196+
},
197+
"extract-i18n": {
198+
"builder": "@angular-devkit/build-angular:extract-i18n"
199+
},
200+
"test": {
201+
"builder": "@angular-devkit/build-angular:karma",
202+
"options": {
203+
"polyfills": [
204+
"zone.js",
205+
"zone.js/testing"
206+
],
207+
"tsConfig": "tsconfig.spec-storybook.json",
208+
"inlineStyleLanguage": "scss",
209+
"assets": [
210+
{
211+
"glob": "**/*",
212+
"input": "public"
213+
}
214+
],
215+
"styles": [
216+
"src-storybook/styles.scss"
217+
],
218+
"scripts": []
219+
}
220+
},
221+
"storybook": {
222+
"builder": "@storybook/angular:start-storybook",
223+
"options": {
224+
"configDir": ".storybook",
225+
"browserTarget": "ng-storybook:build",
226+
"compodoc": true,
227+
"compodocArgs": [
228+
"-e",
229+
"json",
230+
"-d",
231+
"."
232+
],
233+
"port": 6006
234+
}
235+
},
236+
"build-storybook": {
237+
"builder": "@storybook/angular:build-storybook",
238+
"options": {
239+
"configDir": ".storybook",
240+
"browserTarget": "ng-storybook:build",
241+
"compodoc": true,
242+
"compodocArgs": [
243+
"--exportFormat",
244+
"json",
245+
"-d",
246+
"."
247+
],
248+
"outputDir": "storybook-static"
249+
}
250+
},
251+
"lint": {
252+
"builder": "@angular-eslint/builder:lint",
253+
"options": {
254+
"lintFilePatterns": [
255+
"src-storybook/**/*.ts",
256+
"src-storybook/**/*.html"
257+
]
258+
}
259+
}
260+
}
127261
}
128262
},
129263
"cli": {

0 commit comments

Comments
 (0)