Skip to content

Commit f89bb4c

Browse files
authored
Merge pull request #579 from CSSSR/release/blog-17
release: BLOG-17
2 parents f4fb135 + 4497d47 commit f89bb4c

File tree

163 files changed

+7875
-1246
lines changed

Some content is hidden

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

163 files changed

+7875
-1246
lines changed

.github/kuberta.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
version: 1-alpha.1
2+
3+
releases:
4+
csssr-blog-storybook:
5+
name: csssr-blog-storybook
6+
autodeploy-on: default
7+
chart: csssr/static-site@~1.1.0
8+
static-params:
9+
projectID: csssr-blog-storybook
10+
tlsSecret: csssr-blog-storybook-tls
11+
builds:
12+
- workflow: build-storybook.yaml
13+
values:
14+
buildID: build-{{ .Build.RunID }}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Storybook
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
kuberta_system:
6+
7+
jobs:
8+
build:
9+
name: Build Storybook
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: docker://quay.csssr.cloud/csssr/kuberta-init-workflow:v1
14+
15+
- uses: docker://quay.csssr.cloud/csssr/github-info:v1
16+
id: gh
17+
18+
- name: Download CSSSR actions
19+
uses: actions/checkout@v2
20+
with:
21+
repository: CSSSR/actions
22+
ssh-key: ${{ secrets.DOWNLOAD_ACTIONS_SSH_KEY }}
23+
path: actions
24+
25+
- uses: actions/checkout@v2
26+
with:
27+
path: blog
28+
29+
- uses: actions/setup-node@v1
30+
with:
31+
node-version: '14.x'
32+
33+
- run: yarn install --frozen-lockfile
34+
working-directory: blog
35+
36+
- run: yarn build-storybook
37+
working-directory: blog
38+
env:
39+
BLOG_HOST: https://${{ steps.gh.outputs.releaseID }}.csssr-blog-storybook.csssr.cloud/
40+
41+
- uses: ./actions/upload-static/v1beta1
42+
with:
43+
project-id: csssr-blog-storybook
44+
files: ./blog/storybook-static
45+
auth: ${{ secrets.CDN_UPLOAD_SECRET }}
46+
token: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
/node_modules
33
/.next
44
/out
5+
.yalc
6+
yalc.lock
57

68
# IDEs and editors
79
.idea/*

.storybook/main.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const { getImagesLoaderRules } = require('../utils/getImagesLoaderRules');
2+
const { Plugin } = require('@csssr/csssr.images/dist/webpack/plugin');
3+
4+
module.exports = {
5+
stories: [
6+
'../stories/**/*.stories.mdx',
7+
'../stories/**/*.stories.@(js|jsx|ts|tsx)',
8+
],
9+
addons: ['@storybook/addon-links', '@storybook/addon-essentials'],
10+
webpackFinal: (config, { configType }) => {
11+
const isDev = configType === 'DEVELOPMENT';
12+
13+
config.module.rules = config.module.rules.map((rule) => {
14+
// Редактируем существующее правило для избежания конфликтов с @csssr/csssr.images
15+
if (
16+
rule.test.toString() ===
17+
'/\\.(svg|ico|jpg|jpeg|png|apng|gif|eot|otf|webp|ttf|woff|woff2|cur|ani|pdf)(\\?.*)?$/'
18+
) {
19+
rule.test = /\\.(svg|ico|apng|gif|eot|otf|webp|ttf|woff|woff2|cur|ani|pdf)(\\?.*)?$/;
20+
}
21+
22+
return rule;
23+
});
24+
25+
config.module.rules.push(
26+
...getImagesLoaderRules(isDev, true)
27+
);
28+
29+
if (!isDev) {
30+
// TODO подключить позже, нужен для обхода всех картинок проекта перед выкладкой на прод
31+
config.plugins.push(new Plugin());
32+
}
33+
34+
return config;
35+
},
36+
};

.storybook/manager.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { addons } from '@storybook/addons';
2+
3+
addons.setConfig({
4+
showPanel: true,
5+
panelPosition: 'right',
6+
});

.storybook/preview.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
import React from 'react';
2+
import { Global, ThemeProvider, css } from '@emotion/react';
3+
import { Root, Fonts, defaultTheme } from '@csssr/core-design';
4+
import { getTransformSource } from './utils/getTransformSource';
5+
6+
import { Grid } from '../components/Grid';
7+
8+
import stylesBody from '../components/Post/Body/Body.styles';
9+
import stylesLayout from '../components/Layout/Layout.styles';
10+
11+
const customViewports = {
12+
mobile: {
13+
name: 'mobile.all 360px',
14+
styles: {
15+
width: '360px',
16+
height: '640px',
17+
},
18+
},
19+
tablet: {
20+
name: 'tablet.all 1024px',
21+
styles: {
22+
width: '1024px',
23+
height: '768px',
24+
},
25+
},
26+
desktopM: {
27+
name: 'desktop.m 1360px',
28+
styles: {
29+
width: '1360px',
30+
height: '1000px',
31+
},
32+
},
33+
desktopL: {
34+
name: 'desktop.l 1920px',
35+
styles: {
36+
width: '1920px',
37+
height: '1000px',
38+
},
39+
},
40+
};
41+
42+
export const parameters = {
43+
viewport: { viewports: customViewports },
44+
actions: { argTypesRegex: '^on[A-Z].*' },
45+
controls: {
46+
matchers: {
47+
color: /(background|color)$/i,
48+
date: /Date$/,
49+
},
50+
},
51+
docs: {
52+
transformSource: (_src, storyContext) => {
53+
const { args, kind } = storyContext;
54+
return getTransformSource(kind, args);
55+
},
56+
},
57+
};
58+
export const decorators = [
59+
(Story) => (
60+
<Root>
61+
<ThemeProvider theme={defaultTheme}>
62+
<Grid>
63+
<Fonts preset="blog" />
64+
<Story />
65+
<Global styles={stylesLayout} />
66+
<Global styles={(theme) => stylesBody({ theme })} />
67+
{/* Для переопределения стилей блога, иначе код code source в одну строку */}
68+
<Global styles={css`code {
69+
white-space: pre;
70+
}`}/>
71+
</Grid>
72+
</ThemeProvider>
73+
</Root>
74+
),
75+
];
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import prettier from 'prettier';
2+
import parserMdx from 'prettier/parser-markdown';
3+
import parserBabel from 'prettier/parser-babel';
4+
5+
import { getLattices } from '../../stories/utils/getLattices';
6+
import { getStringAttributes } from '../../stories/utils/getStringAttributes';
7+
8+
export const getSource = (kind, args) => {
9+
if (kind === 'Heading') {
10+
const { text, headingLevel } = args;
11+
12+
return `${getLattices(headingLevel)} ${text}`;
13+
}
14+
15+
if (kind === 'Img' || kind === 'Separator') {
16+
return `<${kind} ${getStringAttributes(args)}/>`;
17+
}
18+
19+
if (kind === 'Note' || kind === 'Subtitle') {
20+
const { contentMdx } = args;
21+
22+
return `<${kind}>${contentMdx}</${kind}>`;
23+
}
24+
25+
if (
26+
kind === 'Caption' ||
27+
kind === 'ParagraphWithImage' ||
28+
kind === 'Quote' ||
29+
kind === 'Table'
30+
) {
31+
const { contentMdx, ...rest } = args;
32+
33+
return `<${kind} ${getStringAttributes(rest)}>${contentMdx}</${kind}>`;
34+
}
35+
36+
if (kind === 'Video') {
37+
const { content, ...rest } = args || {};
38+
39+
return content
40+
? `<Video ${getStringAttributes(rest)}>${content}</Video>`
41+
: `<Video ${getStringAttributes(rest)} />`;
42+
}
43+
};
44+
45+
export const getTransformSource = (kind, args) =>
46+
prettier.format(getSource(kind, args), {
47+
parser: 'mdx',
48+
plugins: [parserMdx, parserBabel],
49+
});

.storybook/webpack.config.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
4+
function getPackageDir(filepath) {
5+
let currDir = path.dirname(require.resolve(filepath));
6+
while (true) {
7+
if (fs.existsSync(path.join(currDir, 'package.json'))) {
8+
return currDir;
9+
}
10+
const { dir, root } = path.parse(currDir);
11+
if (dir === root) {
12+
throw new Error(`Could not find package.json in the parent directories starting from ${filepath}.`);
13+
}
14+
currDir = dir;
15+
}
16+
}
17+
18+
module.exports = async ({ config, mode }) => {
19+
if (mode === 'PRODUCTION' && process.env.PUBLIC_PATH) {
20+
config.output.publicPath = process.env.PUBLIC_PATH
21+
}
22+
23+
/**
24+
* Map Emotion 10 libraries to Emotion 11 libraries.
25+
*
26+
* Otherwise Storybook fails to compile with "Module not found: Error: Can't resolve '@emotion/styled/base'", etc.
27+
* It wasn't necessary to do this until we imported React component using "@emotion/styled".
28+
* This issue is probably caused because Storybook uses Emotion 10 while we have Emotion 11 used by the Next.js app.
29+
*
30+
* @see https://github.com/storybookjs/storybook/issues/13277#issuecomment-751747964
31+
* @see https://github.com/storybookjs/storybook/issues/13277#issuecomment-765525245
32+
*/
33+
34+
config.resolve.alias = {
35+
...config.resolve.alias,
36+
"@emotion/core": getPackageDir("@emotion/react"),
37+
"@emotion/styled": getPackageDir("@emotion/styled"),
38+
"emotion-theming": getPackageDir("@emotion/react"),
39+
}
40+
41+
return config
42+
}

_posts/news512/news-130.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ tag: 'news'
77
author: 'Ислам Виндижев'
88
---
99

10-
<Note>
11-
[RSS подкаста](https://radio.csssr.com/rss/news512.rss), [Apple Podcasts](https://podcasts.apple.com/us/podcast/id1370045815), [Google Podcasts](https://podcasts.google.com/?feed=aHR0cHM6Ly9yYWRpby5jc3Nzci5jb20vcnNzL25ld3M1MTIucnNz&ep=14), [SoundCloud](https://soundcloud.com/csssr/sets/512-news), [Я.Музыка](https://music.yandex.ru/album/7040324/track/54795992)
12-
</Note>
13-
1410
<ParagraphWithImage imageName="manWithLaptop" imageSide="right">
1511
### Интересные публикации
1612

_posts/news512/news-131.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ tag: 'news'
77
author: 'Ислам Виндижев'
88
---
99

10-
<Note>
11-
[RSS подкаста](https://radio.csssr.com/rss/news512.rss), [Apple Podcasts](https://podcasts.apple.com/us/podcast/id1370045815), [Google Podcasts](https://podcasts.google.com/?feed=aHR0cHM6Ly9yYWRpby5jc3Nzci5jb20vcnNzL25ld3M1MTIucnNz&ep=14), [SoundCloud](https://soundcloud.com/csssr/sets/512-news), [Я.Музыка](https://music.yandex.ru/album/7040324/track/54795992)
12-
</Note>
13-
1410
<ParagraphWithImage imageName="manWithLaptop" imageSide="right">
1511
### Интересные публикации
1612

0 commit comments

Comments
 (0)