Skip to content

Commit 911524f

Browse files
authored
Merge pull request #185 from CSSSR/release/BLOG-FOOTER-FIX
release: BLOG-FOOTER-FIX
2 parents 540291f + 4d33181 commit 911524f

File tree

115 files changed

+1099
-4964
lines changed

Some content is hidden

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

115 files changed

+1099
-4964
lines changed

.dependabot/config.yml

Lines changed: 0 additions & 9 deletions
This file was deleted.

.github/dependabot.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: npm
4+
directory: "/"
5+
schedule:
6+
interval: daily
7+
time: "08:00"
8+
timezone: Europe/Moscow
9+
open-pull-requests-limit: 10
10+
target-branch: dependabot-update
11+
reviewers:
12+
- ArtyomResh

MONOREPO.md

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,14 @@
33

44
Все зависимости устанавливаются в общую папку `node_modules` (в корневой директории), а внутренние пакеты линкуются между собой.
55

6-
Сейчас репозиторий содержит 3 пакета:
6+
Сейчас репозиторий содержит 2 пакета:
77
* `@csssr/core-design` — основной пакет, библиотека с переиспользуемыми React-компонентами;
8-
* `@csssr/core-docs` — документация, приложение на Next.js, использует компоненты из `@csssr/core-design`;
98
* `@csssr/core-scripts` — cli-утилита для развертывания голого проекта from scratch из файлов-шаблонов и других полезных комманд, которые могут приготиться пользователю библиотеки;
109

11-
Пакеты `@csssr/core-design` и `@csssr/core-scripts` публикуются в npm.
10+
Пакеты публикуются в npm.
1211

1312
## Как разрабатывать
14-
В большинстве случаев нужно:
15-
1. Запустить npm-cкрипт `$ yarn run dev` в директирии `./packages/core-design`;
16-
2. Запустить dev-сервер приложения документации `$ yarn run dev` в директирии `./packages/core-docs`;
13+
Запустить npm-cкрипт `$ yarn start:storybook` в директирии `./packages/core-design`;
1714

1815
## Пакет `@csssr/core-design`
1916
Эту библиотеку подключают в проект (с React-ом), и импортируют из неё компоненты.
@@ -63,14 +60,3 @@ $ core-design --help
6360
2. Выполнить команду `$ npm link`;
6461

6562
Теперь можно локально запускать команду `$ core-design ...`.
66-
67-
## Пакет `@csssr/core-docs`
68-
Это приложение c SSR (на Next.js), которое использует компоненты из библиотеки `@csssr/core-design` для построения документации на неё же.
69-
70-
### Сборка для продашкн
71-
Можно посмотреть в документации Next.js. Если вкратце: происходит запуск npm-скрипта `build`, а после этого `start`. Артифакты сборки попадают в директорию `./packages/core-docs/.next`. Используется конфигурация из файла `./packages/core-docs/next.config.js`
72-
73-
### Сборка для локальной разработки
74-
Запускается скрипт `dev`. Используется конфигурация из файла `./packages/core-docs/next.config.js`, где есть несколько важных особенностей:
75-
1. Добавлен костыль, который добавляет корректную настройку [externals](https://webpack.js.org/configuration/externals/) webpack-конфига SSR-части для пакета `@csssr/core-design`; Это сделано для корректного отслеживания измененных файлов библиотеки, корректной работы HMR;
76-
2. Добавлен плагин для проверки типов;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"license": "MIT",
66
"private": true,
77
"scripts": {
8-
"dev": "lerna run dev --parallel --scope=@csssr/core-{design,docs}",
8+
"dev": "lerna run dev --parallel --scope=@csssr/core-design",
99
"build": "./scripts/build.sh",
1010
"version": "./scripts/version.sh",
1111
"release": "./scripts/release.sh",
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import * as React from 'react'
2+
3+
import { storiesOf } from '@storybook/react'
4+
import { withKnobs, select } from '@storybook/addon-knobs'
5+
6+
import CookiesPopup from './CookiesPopup'
7+
8+
storiesOf('CookiesPopup', module)
9+
.addDecorator(withKnobs)
10+
.add('CookiesPopup', () => {
11+
const knobs = {
12+
preset: select('Preset', ['defaultEn', 'defaultRu', ''], 'defaultEn'),
13+
}
14+
15+
return <CookiesPopup {...knobs} />
16+
})
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
import { css } from '@emotion/react'
2+
import calcRem from '../../utils/style/calcRem'
3+
4+
const base = ({ media }) => css`
5+
& {
6+
z-index: 99999;
7+
position: fixed;
8+
bottom: 0;
9+
left: 0;
10+
width: 100%;
11+
padding-top: ${calcRem(8)};
12+
padding-bottom: ${calcRem(8)};
13+
padding-left: 2rem;
14+
padding-right: 2.265rem;
15+
background-color: #171717;
16+
color: #ffffff;
17+
transition: transform 200ms ease-out, opacity 200ms ease-out;
18+
}
19+
20+
&.hide {
21+
transform: translateY(100%);
22+
opacity: 0;
23+
}
24+
25+
.wrap {
26+
position: relative;
27+
display: flex;
28+
}
29+
30+
.close {
31+
padding: 0;
32+
background-color: transparent;
33+
border: none;
34+
position: absolute;
35+
top: 1rem;
36+
height: 1rem;
37+
color: #ffffff;
38+
cursor: pointer;
39+
}
40+
41+
.cookies-text {
42+
position: relative;
43+
color: #ffffff;
44+
-webkit-text-size-adjust: 100%; /* Prevent font scaling in landscape while allowing user zoom */
45+
}
46+
47+
.cookies-text::after {
48+
content: '';
49+
position: absolute;
50+
right: -172px;
51+
bottom: ${calcRem(-8)};
52+
width: ${calcRem(62)};
53+
height: ${calcRem(53)};
54+
background-image: url(${require('../../static/icons/cookiesPopup/cookie_ready.svg')});
55+
background-repeat: no-repeat;
56+
background-size: cover;
57+
background-position: center;
58+
}
59+
60+
.cookies-link {
61+
text-decoration: underline;
62+
cursor: pointer;
63+
color: #ffffff;
64+
margin-left: 0.25rem;
65+
}
66+
67+
@media (max-width: 1070px) and (min-width: 1025px) {
68+
p.cookies-text {
69+
max-width: ${calcRem(692)};
70+
}
71+
}
72+
73+
${media.from('1025px')} {
74+
& {
75+
padding-top: 0.5rem;
76+
padding-bottom: 0.5rem;
77+
}
78+
79+
.close {
80+
top: ${calcRem(21)};
81+
right: ${calcRem(16)};
82+
width: 1.5rem;
83+
height: 1.5rem;
84+
}
85+
86+
.cookies-text {
87+
max-width: ${calcRem(790)};
88+
}
89+
90+
.cookies-text::after {
91+
bottom: -0.5rem;
92+
}
93+
}
94+
95+
${media.to('1024px')} {
96+
.cookies-text {
97+
max-width: ${calcRem(692)};
98+
}
99+
100+
.cookies-text::after {
101+
right: ${calcRem(-133)};
102+
}
103+
104+
.close {
105+
top: ${calcRem(19)};
106+
right: ${calcRem(15)};
107+
}
108+
}
109+
110+
${media.from('768px')} {
111+
.close {
112+
width: ${calcRem(24)};
113+
height: ${calcRem(24)};
114+
}
115+
}
116+
117+
${media.to('767px')} {
118+
& {
119+
padding-top: ${calcRem(16)};
120+
padding-bottom: ${calcRem(16)};
121+
}
122+
123+
.cookies-text::after {
124+
display: none;
125+
}
126+
127+
.close {
128+
width: ${calcRem(16)};
129+
height: ${calcRem(16)};
130+
}
131+
}
132+
133+
@media (min-device-width: 375px) and (max-device-width: 812px) and (-webkit-min-device-pixel-ratio: 2) and (-webkit-max-device-pixel-ratio: 3) {
134+
& {
135+
padding-top: ${calcRem(12)};
136+
padding-bottom: ${calcRem(12)};
137+
padding-left: ${calcRem(24)};
138+
padding-right: ${calcRem(27)};
139+
}
140+
141+
.wrap {
142+
max-width: unset;
143+
}
144+
145+
.close {
146+
top: ${calcRem(12)};
147+
right: ${calcRem(12)};
148+
width: ${calcRem(12)};
149+
height: ${calcRem(12)};
150+
}
151+
152+
.cookies-text {
153+
font-size: 14px;
154+
line-height: 24px;
155+
}
156+
}
157+
`
158+
159+
const StyledCookiesPopup = (props) => {
160+
const media = props.theme.media
161+
162+
return css`
163+
${base({ media })}
164+
`
165+
}
166+
167+
export default StyledCookiesPopup
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import React, { useEffect, useState } from 'react'
2+
import cn from 'classnames'
3+
import styled from '@emotion/styled'
4+
5+
import Text from '../Text'
6+
import localStorageAvailable from '../../utils/client/localStorageAvailable'
7+
import styles from './CookiesPopup.styles'
8+
9+
import presets from '../../data/cookiesPopupPresets'
10+
11+
/* tslint:disable */
12+
const CrossIcon = require('../../static/icons/cookiesPopup/cross_white.svg')
13+
/* tslint:enable */
14+
15+
const COOKIES_POLICY_ALERT_HIDDEN = 'hidden'
16+
17+
export interface Props {
18+
className?: string
19+
preset?: string
20+
}
21+
22+
const CookiesPopup: React.FC<Props> = ({ className, preset }) => {
23+
const [isHidden, setIsHidden] = useState(true)
24+
25+
const handleClick = () => {
26+
if (localStorageAvailable()) {
27+
localStorage.setItem('cookies_policy', COOKIES_POLICY_ALERT_HIDDEN)
28+
}
29+
setIsHidden(true)
30+
}
31+
32+
useEffect(() => {
33+
if (localStorageAvailable()) {
34+
setIsHidden(localStorage.getItem('cookies_policy') === COOKIES_POLICY_ALERT_HIDDEN)
35+
} else {
36+
setIsHidden(false)
37+
}
38+
}, [])
39+
40+
const links = presets[preset].links
41+
42+
return (
43+
<div className={cn(className, { hide: isHidden })}>
44+
<button className="close" onClick={handleClick}>
45+
<CrossIcon />
46+
</button>
47+
<div className="wrap">
48+
<Text type="regular" size="m" className="cookies-text">
49+
<span dangerouslySetInnerHTML={{ __html: presets[preset].text }} />
50+
51+
{links.map((link) => (
52+
<a
53+
key={link.href}
54+
href={link.href}
55+
target="_blank"
56+
rel="noopener noreferrer"
57+
className="cookies-link"
58+
dangerouslySetInnerHTML={{
59+
__html: link.title,
60+
}}
61+
/>
62+
))}
63+
</Text>
64+
</div>
65+
</div>
66+
)
67+
}
68+
69+
export default styled(CookiesPopup)`
70+
${styles}
71+
`
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default } from './CookiesPopup'

0 commit comments

Comments
 (0)