itube-specs 0.0.922 → 0.0.923
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/DOCS/CONVENTIONS.md +44 -0
- package/DOCS/STYLES.md +127 -0
- package/README.md +6 -0
- package/package.json +3 -2
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Conventions
|
|
2
|
+
|
|
3
|
+
Layer + every site. From an app: `node_modules/itube-specs/DOCS/CONVENTIONS.md`. Styles → `DOCS/STYLES.md`.
|
|
4
|
+
Human-facing rationale → the layer's `README.md` (Russian).
|
|
5
|
+
|
|
6
|
+
## Components
|
|
7
|
+
|
|
8
|
+
`pathPrefix: true` → name = folder path + filename, repeated segments deduped by Nuxt. Folder is the
|
|
9
|
+
namespace; filename must not repeat it.
|
|
10
|
+
|
|
11
|
+
- `ui/icon.vue` → `<UiIcon>` · `player/core.vue` → `<PlayerCore>` · `info/grid.vue` → `<InfoGrid>` (not
|
|
12
|
+
`<InfoInfoGrid>`)
|
|
13
|
+
- Folder root: `index.vue` when the deduped name is already multi-word (`card/video/index.vue` →
|
|
14
|
+
`<CardVideo>`); `main.vue` only when `index.vue` would give one word (`filter/main.vue` → `<FilterMain>`).
|
|
15
|
+
Never a single-word name — clashes with HTML elements.
|
|
16
|
+
- BEM root class = kebab-case of the name: `<CardVideo>` → `.card-video`
|
|
17
|
+
- `pathPrefix: true` mandatory — layers break component exports under `false` (nuxt/nuxt#30099)
|
|
18
|
+
|
|
19
|
+
**App override:** an app defining the same name outranks the layer and wins auto-import; callers untouched.
|
|
20
|
+
Don't fork a component when a prop expresses the difference.
|
|
21
|
+
|
|
22
|
+
## Markup
|
|
23
|
+
|
|
24
|
+
`<div>` is the fallback, not the default.
|
|
25
|
+
|
|
26
|
+
| Need | Tag |
|
|
27
|
+
|---|---|
|
|
28
|
+
| text | `<span>` inline, `<p>` paragraph — never bare `<div>` |
|
|
29
|
+
| structure | `header`, `nav`, `main`, `aside`, `footer`, `section`, `article` |
|
|
30
|
+
| sequence of similar items | `<ul>`/`<ol>` + `<li>` — chip rows and tag clouds included |
|
|
31
|
+
| action / navigation / collapsible | `<button>` / `<a>` / `<details>`+`<summary>` |
|
|
32
|
+
| forms | `<label>`, `<fieldset>`, `<legend>`, native `<input>` types |
|
|
33
|
+
| emphasis, figures | `<em>`/`<strong>`, `<figure>`/`<figcaption>` — not style-only spans |
|
|
34
|
+
|
|
35
|
+
## TypeScript
|
|
36
|
+
|
|
37
|
+
- Semicolons always. No code comments unless asked.
|
|
38
|
+
- Domain string sets: `as const` PascalCase objects in `runtime/constants/`, type via
|
|
39
|
+
`typeof X[keyof typeof X]`. Never `enum` — it survives into the bundle, and `import type` erases it so
|
|
40
|
+
`X.Member` is `undefined` at runtime in a published layer; you also can't assign a raw API/URL/cookie string
|
|
41
|
+
to an enum. String values, not numeric (`0` is falsy — `if (spotType)` misreads member `0` as absent;
|
|
42
|
+
`AdSpotType` is numeric, a wart, don't copy). Framework unions (Nuxt status) stay unions.
|
|
43
|
+
- `.vue` templates are NOT typechecked — `tsc` doesn't read them, `vue-tsc` isn't a gate. A clean `tsc` says
|
|
44
|
+
nothing about template expressions. Read them, or `npx vue-tsc --noEmit` ad hoc past pre-existing noise.
|
package/DOCS/STYLES.md
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# Styles
|
|
2
|
+
|
|
3
|
+
Canonical for every itube site — the layer owns 100% of the SCSS; apps have an empty `assets/scss/` override
|
|
4
|
+
slot. Read before touching any `<style lang="scss">`, `assets/scss/**`, or a theme token. Paths are
|
|
5
|
+
layer-relative; from an app: `node_modules/itube-specs/DOCS/STYLES.md`. Human-facing version → `README.md`.
|
|
6
|
+
|
|
7
|
+
## Co-location
|
|
8
|
+
|
|
9
|
+
- Component and page styles in the SFC's own `<style lang="scss">`. **No `scoped`** — flat BEM isolates.
|
|
10
|
+
- Nothing per-component or per-page in `assets/scss/`.
|
|
11
|
+
- Tree: `assets/scss/` → `vars/` (palette, vars, tokens, z-index), `themes/`, `mixins/`, `base/`, `layout/`,
|
|
12
|
+
`main.scss`. `css` entry is `main.scss`, loads only `vars/tokens`, `base`, `layout`.
|
|
13
|
+
- **Never `@use 'vars'`/`'mixins'` in an SFC block** — auto-injected by the *app's*
|
|
14
|
+
`vite.css.preprocessorOptions.scss.additionalData` + `loadPaths`.
|
|
15
|
+
- Sass-loaded global partials: `@use` relatively within their own root, bare specifiers across roots
|
|
16
|
+
(layer↔app) so `loadPaths` resolves.
|
|
17
|
+
- The layer has no `sass` package — layer styles compile only inside an app, never in the layer's vitest.
|
|
18
|
+
|
|
19
|
+
## Themes
|
|
20
|
+
|
|
21
|
+
Dir per theme: `assets/scss/themes/<name>/_theme.scss`. App picks one via `theme:` in its
|
|
22
|
+
`config/site.config.ts` (read by its `nuxt.config.ts` *and* `app.config.ts` — `useAppConfig()` doesn't exist at
|
|
23
|
+
config time), appends `themes/<theme>/` to `loadPaths`; `@forward 'theme'` in `vars/_index.scss` resolves
|
|
24
|
+
there because no `_theme.scss` sits beside it.
|
|
25
|
+
|
|
26
|
+
**Dir-per-theme is load-bearing** — Sass needs a literal `@use`/`@forward` path, so only the folder can vary.
|
|
27
|
+
|
|
28
|
+
`loadPaths = [<app>/assets/scss, <layer>/assets/scss/themes/<theme>, <layer>/assets/scss]`. App first → a site
|
|
29
|
+
overrides any partial by name (its `vars/_theme.scss` wins over loadPaths).
|
|
30
|
+
|
|
31
|
+
**Every token must exist in every theme** — a missing one is a hard Sass error that kills the app build. Two
|
|
32
|
+
guards, both pre-commit + CI:
|
|
33
|
+
|
|
34
|
+
| Script | Proves | Blind spot |
|
|
35
|
+
|---|---|---|
|
|
36
|
+
| `check:themes` | themes declare the same top-level `$name:` set (`$surfaces` / `$button-variant-overrides` contents ignored — a theme may leave either empty) | token declared in **no** theme |
|
|
37
|
+
| `check:styles` | every `<style>` block compiles against every theme, same preamble + loadPaths as Vite; names the failing theme (~1.5s) | — |
|
|
38
|
+
|
|
39
|
+
## BEM
|
|
40
|
+
|
|
41
|
+
`.block {}`, `.block__element {}`, `.block.--modifier {}` — modifier prefix `--`.
|
|
42
|
+
|
|
43
|
+
**No nesting**, every selector flat with its full class name. `&` only for pseudo-classes, pseudo-elements,
|
|
44
|
+
state modifiers (`&::after`, `&:focus-visible`, `&.--open`).
|
|
45
|
+
|
|
46
|
+
```scss
|
|
47
|
+
.layout-header {}
|
|
48
|
+
.layout-header__logo {} // not .layout-header { &__logo {} }
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Hover
|
|
52
|
+
|
|
53
|
+
**Always `@include hover(<properties>)`, never `&:hover`.** Wraps in `@media (hover: hover)` (on touch a hover
|
|
54
|
+
sticks after a tap), declares `--transition` for the listed properties, pairs `:hover` with `:focus-visible`.
|
|
55
|
+
|
|
56
|
+
```scss
|
|
57
|
+
.ui-btn.--muted {
|
|
58
|
+
@include hover(background-color, border) { background-color: $button-muted-bg--hover; }
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Applies to the current selector only, so hovering one element to restyle another is written flat inside your
|
|
63
|
+
own media query:
|
|
64
|
+
|
|
65
|
+
```scss
|
|
66
|
+
@media (hover: hover) {
|
|
67
|
+
.card-round:is(:hover, :focus-visible) .card-round__img { transform: scale(1.05); }
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Tokens
|
|
72
|
+
|
|
73
|
+
Never hardcode a color, size or z-index.
|
|
74
|
+
|
|
75
|
+
| File | Holds | Type |
|
|
76
|
+
|---|---|---|
|
|
77
|
+
| `vars/_palette.scss` | `$color-indigo-600` — raw palette | SCSS var |
|
|
78
|
+
| `themes/<theme>/_theme.scss` | `$chips-text`, `$button-bg--hover` — colors, one per theme | SCSS var |
|
|
79
|
+
| `vars/_vars.scss` | `$radius-*`, `$blur-*`, `$spacing` — static non-color | SCSS var |
|
|
80
|
+
| `vars/_tokens.scss` | `--header-height` — changes at a breakpoint or set via JS | CSS custom prop |
|
|
81
|
+
|
|
82
|
+
- Changes at a breakpoint or set via JS → CSS custom property. Everything else → SCSS var.
|
|
83
|
+
- **Palette is private**, consumed only by theme files. A component must never use `$color-*` — add the token
|
|
84
|
+
to **every** theme first.
|
|
85
|
+
- **No semantic tier** (`$text-muted`, `$role-border-subtle`) — themes reference palette directly.
|
|
86
|
+
- Theme files hold **colors only**; radius/blur/static → `vars/_vars.scss`.
|
|
87
|
+
|
|
88
|
+
### Context-dependent colors
|
|
89
|
+
|
|
90
|
+
Never a theme flag in a component. Two mixins, driven from the theme file:
|
|
91
|
+
|
|
92
|
+
- `surface($name)` — block declares itself an island (`.ui-popup { @include surface(overlay); }`), contents
|
|
93
|
+
pick up colors by cascade. Theme supplies deltas via `$surfaces`; no differentiation → `$surfaces: ()`.
|
|
94
|
+
Components read `var(--input-bg, #{$input-bg})`, so a single color can still be overridden directly.
|
|
95
|
+
- `button-variant($key)` — place asks, theme answers by name via `$button-variant-overrides`. The element's
|
|
96
|
+
class still reflects the `theme=` prop, so the mixin prints `--button-variant` as a DevTools marker.
|
|
97
|
+
|
|
98
|
+
`appConfig.theme` — structural differences only (different element, extra icon, `v-if`).
|
|
99
|
+
|
|
100
|
+
### Naming
|
|
101
|
+
|
|
102
|
+
`$<block>-<element>?-<modifier>?-<property>-<state>?`
|
|
103
|
+
|
|
104
|
+
- block = component root · element = BEM element, optional · modifier = variant, optional
|
|
105
|
+
- property — always present, always short: `bg`, `text`, `border`, `radius`, `icon`, `shadow`. Never the full
|
|
106
|
+
CSS name (`$button-background` → `$button-bg`, `$input-border-radius` → `$input-radius`). `color` is banned
|
|
107
|
+
as a property — ambiguous, use `text`.
|
|
108
|
+
- state — last, after `--`: `hover`, `active`, `focus`, `disabled`, `checked`, `current`, `error`
|
|
109
|
+
|
|
110
|
+
State goes last even when it reads worse: `$video-playlist-card-bg--active`, NOT
|
|
111
|
+
`$video-playlist-card-active-bg`. A state-looking word can be a sub-element: `$filter-popup-active-chip-bg` is
|
|
112
|
+
`active-chip`.
|
|
113
|
+
|
|
114
|
+
Text-only elements (`title`, `name`, `subtext`, `description`, `label`, `count`) may drop `-text`:
|
|
115
|
+
`$video-card-title`.
|
|
116
|
+
|
|
117
|
+
## Typography and breakpoints
|
|
118
|
+
|
|
119
|
+
- Type: `@include font-sm` (14/20), `font-xs` (12/16), `font-base` (16/24) — never raw
|
|
120
|
+
`font-size`/`line-height`.
|
|
121
|
+
- Breakpoints: `@include from-br(sm)`, `to-br(xs)`. Container: `from-cq($bp)`. JS mirror of `$brkpnts` in
|
|
122
|
+
`config/`, guarded by `check:breakpoints`.
|
|
123
|
+
|
|
124
|
+
**All mixins** (auto-injected, never `@use`): `font-4xs|3xs|xs|2xs|sm|md|base|lg|xl|2xl|3xl|4xl`,
|
|
125
|
+
`from-br|to-br`, `from-cq|to-cq`, `hover`, `surface`, `button-variant`, `page|page-title|page-footer-links`,
|
|
126
|
+
`video-card|video-card-grid|video-card-poster`, `area-point`. Signatures — SCSS-mixins table in the app's
|
|
127
|
+
`DOCS/CATALOG.md`.
|
package/README.md
CHANGED
|
@@ -143,6 +143,12 @@ assets/scss/themes/dark/_theme.scss
|
|
|
143
143
|
подставляет приложение, и компилирует по разу на тему. То же, что делает Vite, — значит ловит и неизвестные
|
|
144
144
|
миксины, и неверные аргументы `@include`, и показывает, в какой теме падает.
|
|
145
145
|
|
|
146
|
+
**Промежуточного семантического слоя нет** — темы ссылаются на палитру напрямую, без тира вида
|
|
147
|
+
`$text-muted` / `$role-border-subtle`. Сайты форкаются с принципиально разными схемами, и каждому
|
|
148
|
+
селектору может понадобиться произвольный цвет, а не одна из горстки ролей. Такой слой либо оброс бы
|
|
149
|
+
ролью на селектор (и перестал быть семантическим), либо компоненты начали бы тянуться в обход него.
|
|
150
|
+
Имя токена по компоненту, который он обслуживает, держит соответствие честным.
|
|
151
|
+
|
|
146
152
|
Контекстные различия (контрол внутри попапа, вариант кнопки, зависящий от темы) решают миксины
|
|
147
153
|
`surface()` и `button-variant()` из `mixins/`: место объявляет себя, а значения даёт тема через карты
|
|
148
154
|
`$surfaces` / `$button-variant-overrides`. Компоненты про темы не знают. `appConfig.theme` — только
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "itube-specs",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.923",
|
|
5
5
|
"main": "./nuxt.config.ts",
|
|
6
6
|
"types": "./types/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
@@ -74,7 +74,8 @@
|
|
|
74
74
|
"assets/scss/base/",
|
|
75
75
|
"assets/scss/layout/",
|
|
76
76
|
"assets/scss/main.scss",
|
|
77
|
-
"nuxt.config.ts"
|
|
77
|
+
"nuxt.config.ts",
|
|
78
|
+
"DOCS/"
|
|
78
79
|
],
|
|
79
80
|
"devDependencies": {
|
|
80
81
|
"@intlify/eslint-plugin-vue-i18n": "^4.5.1",
|