nightcss 0.0.0-stage → 0.1.0-alpha.0
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/LICENSE +21 -0
- package/README.md +292 -2
- package/README.ru.md +293 -0
- package/dist/base.css +158 -0
- package/dist/base.min.css +1 -0
- package/dist/layout.css +185 -0
- package/dist/layout.min.css +1 -0
- package/dist/nightcss.css +1206 -0
- package/dist/nightcss.min.css +1 -0
- package/dist/reset.css +59 -0
- package/dist/reset.min.css +1 -0
- package/dist/themes/dark.css +8 -0
- package/dist/themes/dark.min.css +1 -0
- package/dist/themes/light.css +8 -0
- package/dist/themes/light.min.css +1 -0
- package/dist/tokens.css +161 -0
- package/dist/tokens.min.css +1 -0
- package/dist/utilities.css +644 -0
- package/dist/utilities.min.css +1 -0
- package/package.json +65 -4
- package/src/scss/_functions.scss +136 -0
- package/src/scss/_mixins.scss +90 -0
- package/src/scss/_tokens.scss +148 -0
- package/src/scss/index.scss +21 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 nightrunner91
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,293 @@
|
|
|
1
|
-
#
|
|
1
|
+
# <p align="center">NightCSS</p>
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<p align="center">
|
|
4
|
+
<strong>A design system in a single CSS file.</strong>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<strong><img src="https://flagcdn.com/w20/us.png" width="20"> English</strong> | <a href="README.ru.md"><img src="https://flagcdn.com/w20/ru.png" width="20"> Russian</a>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<img src="https://img.shields.io/badge/Version-0.1.0--alpha.0-blue?style=for-the-badge" alt="Version">
|
|
13
|
+
<img src="https://img.shields.io/badge/License-MIT-green?style=for-the-badge" alt="License">
|
|
14
|
+
<img src="https://img.shields.io/badge/Node.js-%3E%3D18-6da55f?style=for-the-badge&logo=node.js" alt="Node Version">
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
## Table of Contents
|
|
18
|
+
|
|
19
|
+
- [Project Overview](#project-overview)
|
|
20
|
+
- [Features](#features)
|
|
21
|
+
- [Tech Stack](#tech-stack)
|
|
22
|
+
- [Project Structure](#project-structure)
|
|
23
|
+
- [Getting Started](#getting-started)
|
|
24
|
+
- [Prerequisites](#prerequisites)
|
|
25
|
+
- [Installation](#installation)
|
|
26
|
+
- [Quick Start](#quick-start)
|
|
27
|
+
- [Usage](#usage)
|
|
28
|
+
- [Configuration](#configuration)
|
|
29
|
+
- [Theming](#theming)
|
|
30
|
+
- [Roadmap](#roadmap)
|
|
31
|
+
- [Development](#development)
|
|
32
|
+
- [Available Scripts](#available-scripts)
|
|
33
|
+
- [Running Tests](#running-tests)
|
|
34
|
+
- [Contributing](#contributing)
|
|
35
|
+
- [License](#license)
|
|
36
|
+
|
|
37
|
+
## Project Overview
|
|
38
|
+
|
|
39
|
+
NightCSS is a drop-in CSS foundation. Link one stylesheet and your page gets a modern reset, sensible defaults for headings, forms, and media, and a complete set of `--nc-*` design tokens for color, typography, spacing, and dark mode. It is plain CSS built on `@layer` and custom properties: you theme it by overriding variables, and your own unlayered styles always win.
|
|
40
|
+
|
|
41
|
+
It sits between a bare reset and a full framework — more than a reset, because of the tokens and theming, and less than Bootstrap, because there are no components and no JavaScript. NightCSS is a reimagining of the author's earlier [NightVue](https://github.com/nightrunner91/nightvue) and [NightPack](https://github.com/nightrunner91/nightpack) projects for modern web development in 2026-2027.
|
|
42
|
+
|
|
43
|
+
> [!NOTE]
|
|
44
|
+
> NightCSS is pre-release (`0.1.0-alpha.0`). The current version ships tokens, the reset, base styles, theming, utility classes, layout primitives, and the optional Sass subpackage. The documentation site is the next milestone.
|
|
45
|
+
|
|
46
|
+
## Features
|
|
47
|
+
|
|
48
|
+
- **Zero build step** — one `<link>` or `@import`; no bundler, no PostCSS chain, no config file.
|
|
49
|
+
- **Cascading layers** — `@layer` gives predictable specificity; your own unlayered CSS always wins, with no `!important`.
|
|
50
|
+
- **Design tokens** — `--nc-*` custom properties for color, type, space, radius, shadow, motion, and z-index.
|
|
51
|
+
- **Runtime theming** — light/dark through `light-dark()` and `color-scheme`, with `[data-theme]` overrides.
|
|
52
|
+
- **Modern reset and base** — Andy Bell-school reset plus sensible element, form, and media defaults.
|
|
53
|
+
- **Token escape hatch** — every scale utility reads a `--nc-*` variable with a fallback, so arbitrary values work without a build.
|
|
54
|
+
- **Utility classes** — Tailwind-compatible muscle memory: spacing, sizing, flexbox, typography, color, border, shadow, position, overflow, interaction, and a11y.
|
|
55
|
+
- **Layout primitives** — `container`, `grid`, `stack`, `cluster`, `sidebar`, `switcher`, `cover`, and `frame`, implemented with `gap`, `flex-wrap`, and `min()`/`clamp()` instead of media queries.
|
|
56
|
+
|
|
57
|
+
## Tech Stack
|
|
58
|
+
|
|
59
|
+
| Technology | Purpose |
|
|
60
|
+
|---|---|
|
|
61
|
+
| [CSS](https://developer.mozilla.org/en-US/docs/Web/CSS) | The product itself: tokens, layers, reset, base, utilities |
|
|
62
|
+
| [Lightning CSS](https://lightningcss.dev/) | Minification and prefixing in the build script |
|
|
63
|
+
| [Node.js](https://nodejs.org/) | Build and test tooling (no runtime dependency) |
|
|
64
|
+
|
|
65
|
+
## Project Structure
|
|
66
|
+
|
|
67
|
+
```text
|
|
68
|
+
nightcss/
|
|
69
|
+
├── src/
|
|
70
|
+
│ ├── index.css # Entry: layer order + module imports
|
|
71
|
+
│ ├── reset.css # Modern reset (Andy Bell school)
|
|
72
|
+
│ ├── tokens/ # Design tokens (--nc-*)
|
|
73
|
+
│ │ ├── color.css
|
|
74
|
+
│ │ ├── type.css
|
|
75
|
+
│ │ ├── space.css
|
|
76
|
+
│ │ ├── radius.css
|
|
77
|
+
│ │ ├── shadow.css
|
|
78
|
+
│ │ ├── motion.css
|
|
79
|
+
│ │ ├── z.css
|
|
80
|
+
│ │ └── breakpoint.css
|
|
81
|
+
│ ├── base/ # Base element styles
|
|
82
|
+
│ │ ├── elements.css
|
|
83
|
+
│ │ ├── forms.css
|
|
84
|
+
│ │ └── media.css
|
|
85
|
+
│ ├── layout/ # Layout primitives
|
|
86
|
+
│ │ ├── container.css
|
|
87
|
+
│ │ ├── grid.css
|
|
88
|
+
│ │ ├── stack.css
|
|
89
|
+
│ │ ├── cluster.css
|
|
90
|
+
│ │ ├── sidebar.css
|
|
91
|
+
│ │ ├── switcher.css
|
|
92
|
+
│ │ ├── cover.css
|
|
93
|
+
│ │ └── frame.css
|
|
94
|
+
│ ├── utilities/ # Utility classes
|
|
95
|
+
│ │ ├── display.css
|
|
96
|
+
│ │ ├── flex.css
|
|
97
|
+
│ │ ├── spacing.css
|
|
98
|
+
│ │ ├── sizing.css
|
|
99
|
+
│ │ ├── typography.css
|
|
100
|
+
│ │ ├── color.css
|
|
101
|
+
│ │ ├── border.css
|
|
102
|
+
│ │ ├── shadow.css
|
|
103
|
+
│ │ ├── position.css
|
|
104
|
+
│ │ ├── overflow.css
|
|
105
|
+
│ │ ├── interaction.css
|
|
106
|
+
│ │ └── a11y.css
|
|
107
|
+
│ ├── themes/ # Opt-in [data-theme] overrides
|
|
108
|
+
│ │ ├── light.css
|
|
109
|
+
│ │ └── dark.css
|
|
110
|
+
│ └── legacy/ # NightVue SCSS core (reference only)
|
|
111
|
+
├── scripts/
|
|
112
|
+
│ └── build.mjs # Lightning CSS build
|
|
113
|
+
├── tests/
|
|
114
|
+
│ ├── size.mjs # Size budget assertions
|
|
115
|
+
│ └── layer-order.mjs # Layer order and !important checks
|
|
116
|
+
├── package.json
|
|
117
|
+
├── LICENSE
|
|
118
|
+
├── README.md
|
|
119
|
+
└── README.ru.md
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Getting Started
|
|
123
|
+
|
|
124
|
+
### Prerequisites
|
|
125
|
+
|
|
126
|
+
- [Node.js](https://nodejs.org/) `>=18` (build tooling only — NightCSS has no runtime dependency).
|
|
127
|
+
|
|
128
|
+
### Installation
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
git clone https://github.com/nightrunner91/nightcss.git
|
|
132
|
+
cd nightcss
|
|
133
|
+
npm install
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Quick Start
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
npm run build
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
This writes the compiled CSS to `dist/`, including the full bundle (`nightcss.css`) and minified modules.
|
|
143
|
+
|
|
144
|
+
## Usage
|
|
145
|
+
|
|
146
|
+
Add the compiled stylesheet to your page:
|
|
147
|
+
|
|
148
|
+
```html
|
|
149
|
+
<link rel="stylesheet" href="dist/nightcss.css">
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Or install from npm and import it:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
npm install nightcss
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
```css
|
|
159
|
+
@import "nightcss";
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Individual modules are exported too:
|
|
163
|
+
|
|
164
|
+
```css
|
|
165
|
+
@import "nightcss/reset";
|
|
166
|
+
@import "nightcss/tokens";
|
|
167
|
+
@import "nightcss/base";
|
|
168
|
+
@import "nightcss/layout";
|
|
169
|
+
@import "nightcss/utilities";
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Sass subpackage
|
|
173
|
+
|
|
174
|
+
NightCSS also ships an optional Sass subpackage (`nightcss/scss`) for projects that write SCSS: token maps, `var(--nc-*)` accessor functions, `color-mix(in oklch)` color helpers, and a few small mixins — all on the modern module system (`@use`/`@forward`, `sass:map`, no `!important`, no `@import`).
|
|
175
|
+
|
|
176
|
+
```scss
|
|
177
|
+
@use "nightcss/scss" as nc;
|
|
178
|
+
|
|
179
|
+
.card {
|
|
180
|
+
padding: nc.nc-space(4);
|
|
181
|
+
border-radius: nc.nc-radius("md");
|
|
182
|
+
box-shadow: nc.nc-shadow("md");
|
|
183
|
+
color: nc.nc-color("text");
|
|
184
|
+
background: nc.nc-tint(nc.nc-color("accent"), 92%);
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
The token maps are re-exported too, for compile-time access and math: `map.get(nc.$nc-space, 4)` → `1rem`.
|
|
189
|
+
|
|
190
|
+
That is all there is to it — NightCSS needs no JavaScript and no bundler configuration.
|
|
191
|
+
|
|
192
|
+
## Configuration
|
|
193
|
+
|
|
194
|
+
NightCSS is configured entirely through CSS custom properties. Override any token on `:root` to re-theme the foundation at runtime:
|
|
195
|
+
|
|
196
|
+
```css
|
|
197
|
+
:root {
|
|
198
|
+
--nc-accent: oklch(45% 0.2 280);
|
|
199
|
+
--nc-radius-md: 0.75rem;
|
|
200
|
+
--nc-space-4: 1.25rem;
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
| Group | Tokens |
|
|
205
|
+
|---|---|
|
|
206
|
+
| Color | `--nc-accent`, `--nc-accent-contrast`, `--nc-surface`, `--nc-surface-raised`, `--nc-text`, `--nc-text-muted`, `--nc-border`, `--nc-ring` |
|
|
207
|
+
| Type | `--nc-font-sans`, `--nc-font-mono`, `--nc-text-xs`…`--nc-text-4xl`, `--nc-leading-*`, `--nc-tracking-*`, `--nc-weight-*` |
|
|
208
|
+
| Space | `--nc-space-0`…`--nc-space-24` (4px steps) |
|
|
209
|
+
| Radius | `--nc-radius-none`, `--nc-radius-sm`, `--nc-radius-md`, `--nc-radius-lg`, `--nc-radius-xl`, `--nc-radius-full` |
|
|
210
|
+
| Shadow | `--nc-shadow-xs`, `--nc-shadow-sm`, `--nc-shadow-md`, `--nc-shadow-lg` |
|
|
211
|
+
| Motion | `--nc-duration-fast`, `--nc-duration-base`, `--nc-duration-slow`, `--nc-ease-standard`, `--nc-ease-emphasized` |
|
|
212
|
+
| Z-index | `--nc-z-base`, `--nc-z-dropdown`, `--nc-z-sticky`, `--nc-z-overlay`, `--nc-z-modal`, `--nc-z-toast` |
|
|
213
|
+
|
|
214
|
+
### Escape hatch
|
|
215
|
+
|
|
216
|
+
Every scale utility reads a short custom property with a token fallback, so arbitrary values work inline without a build:
|
|
217
|
+
|
|
218
|
+
```html
|
|
219
|
+
<div class="p-4" style="--p: 37px">
|
|
220
|
+
<div class="w-4" style="--w: 12rem"></div>
|
|
221
|
+
</div>
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
| Family | Variable |
|
|
225
|
+
|---|---|
|
|
226
|
+
| Padding (`p-*`, `px-*`, `py-*`) | `--p` |
|
|
227
|
+
| Margin (`m-*`, `mx-*`, `my-*`) | `--m` |
|
|
228
|
+
| Gap (`gap-*`) | `--gap` |
|
|
229
|
+
| Vertical rhythm (`space-y-*`) | `--space-y` |
|
|
230
|
+
| Width / height (`w-*`, `h-*`) | `--w`, `--h` |
|
|
231
|
+
| Min/max dimensions | `--min-w`, `--max-w`, `--min-h` |
|
|
232
|
+
| Border radius (`rounded-*`) | `--radius` |
|
|
233
|
+
| Font size (`text-*`) | `--text-size` |
|
|
234
|
+
| Box shadow (`shadow-*`) | `--shadow` |
|
|
235
|
+
|
|
236
|
+
### Theming
|
|
237
|
+
|
|
238
|
+
The theme follows the operating system's `color-scheme` automatically via `light-dark()`. To force a theme, set a `data-theme` attribute and import the matching override:
|
|
239
|
+
|
|
240
|
+
```html
|
|
241
|
+
<html data-theme="dark">
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
```css
|
|
245
|
+
@import "nightcss/themes/dark";
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
## Roadmap
|
|
249
|
+
|
|
250
|
+
- **`0.1.0-alpha.0` (current)** — tokens, reset, base styles, theming, utility classes, layout primitives, and the Sass subpackage.
|
|
251
|
+
- **Next** — documentation site and native-pattern guides (`<dialog>`, `popover`, `<details>`, `:has()`).
|
|
252
|
+
- **Later** — the `1.0.0` API freeze and publication.
|
|
253
|
+
|
|
254
|
+
## Development
|
|
255
|
+
|
|
256
|
+
### Available Scripts
|
|
257
|
+
|
|
258
|
+
| Command | Description |
|
|
259
|
+
|---|---|
|
|
260
|
+
| `npm run build` | Bundle and minify the CSS into `dist/` |
|
|
261
|
+
| `npm run lint` | Lint the source CSS with Stylelint |
|
|
262
|
+
| `npm test` | Run the size, layer-order, and Sass tests |
|
|
263
|
+
| `npm run test:size` | Check the gzip size budget |
|
|
264
|
+
| `npm run test:layers` | Verify layer order, `!important`-freedom, and no duplicate selectors |
|
|
265
|
+
| `npm run test:scss` | Compile the Sass subpackage and verify it is modernized |
|
|
266
|
+
|
|
267
|
+
### Running Tests
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
npm test
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
The suite asserts the core bundle stays under 8 KB gzip, the full bundle stays under 25 KB gzip, and that the layer order, `!important`-free guarantee, and duplicate-free output hold in the compiled CSS.
|
|
274
|
+
|
|
275
|
+
## Contributing
|
|
276
|
+
|
|
277
|
+
Contributions are welcome. Please open an issue first to discuss the change you would like to make.
|
|
278
|
+
|
|
279
|
+
1. Fork the project.
|
|
280
|
+
2. Create a feature branch.
|
|
281
|
+
3. Commit your changes.
|
|
282
|
+
4. Push to the branch.
|
|
283
|
+
5. Open a pull request.
|
|
284
|
+
|
|
285
|
+
## License
|
|
286
|
+
|
|
287
|
+
This project is licensed under the [MIT License](LICENSE).
|
|
288
|
+
|
|
289
|
+
---
|
|
290
|
+
|
|
291
|
+
<p align="center">
|
|
292
|
+
Built with ❤ by <a href="https://t.me/nightrunner91">nightrunner91</a>
|
|
293
|
+
</p>
|
package/README.ru.md
ADDED
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
# <p align="center">NightCSS</p>
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<strong>Дизайн-система в одном CSS-файле.</strong>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="README.md"><img src="https://flagcdn.com/w20/us.png" width="20"> English</a> | <strong><img src="https://flagcdn.com/w20/ru.png" width="20"> Русский</strong>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<img src="https://img.shields.io/badge/Version-0.1.0--alpha.0-blue?style=for-the-badge" alt="Версия">
|
|
13
|
+
<img src="https://img.shields.io/badge/License-MIT-green?style=for-the-badge" alt="Лицензия">
|
|
14
|
+
<img src="https://img.shields.io/badge/Node.js-%3E%3D18-6da55f?style=for-the-badge&logo=node.js" alt="Версия Node">
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
## Содержание
|
|
18
|
+
|
|
19
|
+
- [Обзор проекта](#обзор-проекта)
|
|
20
|
+
- [Возможности](#возможности)
|
|
21
|
+
- [Технологический стек](#технологический-стек)
|
|
22
|
+
- [Структура проекта](#структура-проекта)
|
|
23
|
+
- [Начало работы](#начало-работы)
|
|
24
|
+
- [Требования](#требования)
|
|
25
|
+
- [Установка](#установка)
|
|
26
|
+
- [Быстрый старт](#быстрый-старт)
|
|
27
|
+
- [Использование](#использование)
|
|
28
|
+
- [Конфигурация](#конфигурация)
|
|
29
|
+
- [Темизация](#темизация)
|
|
30
|
+
- [План развития](#план-развития)
|
|
31
|
+
- [Разработка](#разработка)
|
|
32
|
+
- [Доступные скрипты](#доступные-скрипты)
|
|
33
|
+
- [Запуск тестов](#запуск-тестов)
|
|
34
|
+
- [Участие в разработке](#участие-в-разработке)
|
|
35
|
+
- [Лицензия](#лицензия)
|
|
36
|
+
|
|
37
|
+
## Обзор проекта
|
|
38
|
+
|
|
39
|
+
NightCSS — это подключаемый CSS-фундамент. Подключаете один стиль — и страница получает современный сброс, разумные стили заголовков, форм и медиа, а также полный набор дизайн-токенов `--nc-*` для цвета, типографики, отступов и тёмной темы. Это обычный CSS на `@layer` и custom properties: тема меняется переопределением переменных, а ваш собственный CSS вне слоёв всегда побеждает.
|
|
40
|
+
|
|
41
|
+
Он занимает место между голым сбросом и полноценным фреймворком — больше, чем сброс (есть токены и темизация), и меньше, чем Bootstrap (нет компонентов и JavaScript). NightCSS — это переосмысление предыдущих проектов автора, [NightVue](https://github.com/nightrunner91/nightvue) и [NightPack](https://github.com/nightrunner91/nightpack), под современный CSS в 2026-2027 году.
|
|
42
|
+
|
|
43
|
+
> [!NOTE]
|
|
44
|
+
> NightCSS находится на стадии предрелиза (`0.1.0-alpha.0`). Текущая версия включает токены, сброс, базовые стили, темизацию, утилиты, layout-примитивы и опциональный Sass-сабпак. Следующий этап — сайт документации.
|
|
45
|
+
|
|
46
|
+
## Возможности
|
|
47
|
+
|
|
48
|
+
- **Ноль сборки** — один `<link>` или `@import`; без бандлера, без цепочки PostCSS, без файла конфигурации.
|
|
49
|
+
- **Каскадные слои** — `@layer` даёт предсказуемую специфичность; ваш собственный CSS вне слоёв всегда побеждает, без `!important`.
|
|
50
|
+
- **Дизайн-токены** — custom properties `--nc-*` для цвета, типографики, отступов, радиусов, теней, движения и z-index.
|
|
51
|
+
- **Темизация в рантайме** — светлая/тёмная тема через `light-dark()` и `color-scheme`, с переопределением через `[data-theme]`.
|
|
52
|
+
- **Современный сброс и база** — сброс в духе Andy Bell плюс разумные стили элементов, форм и медиа.
|
|
53
|
+
- **Escape hatch для токенов** — каждая scale-утилита читает переменную `--nc-*` с фолбэком, поэтому произвольные значения работают без сборки.
|
|
54
|
+
- **Утилитарные классы** — совместимые с мышечной памятью Tailwind: отступы, размеры, flexbox, типографика, цвет, границы, тени, позиционирование, overflow, интерактивность и a11y.
|
|
55
|
+
- **Layout-примитивы** — `container`, `grid`, `stack`, `cluster`, `sidebar`, `switcher`, `cover` и `frame`, реализованные через `gap`, `flex-wrap` и `min()`/`clamp()` вместо медиа-запросов.
|
|
56
|
+
|
|
57
|
+
## Технологический стек
|
|
58
|
+
|
|
59
|
+
| Технология | Назначение |
|
|
60
|
+
|---|---|
|
|
61
|
+
| [CSS](https://developer.mozilla.org/ru/docs/Web/CSS) | Сам продукт: токены, слои, сброс, база, утилиты |
|
|
62
|
+
| [Lightning CSS](https://lightningcss.dev/) | Минификация и автопрефиксы в скрипте сборки |
|
|
63
|
+
| [Node.js](https://nodejs.org/) | Инструменты сборки и тестов (рантайм-зависимостей нет) |
|
|
64
|
+
|
|
65
|
+
## Структура проекта
|
|
66
|
+
|
|
67
|
+
```text
|
|
68
|
+
nightcss/
|
|
69
|
+
├── src/
|
|
70
|
+
│ ├── index.css # Точка входа: порядок слоёв + импорты модулей
|
|
71
|
+
│ ├── reset.css # Современный сброс (в духе Andy Bell)
|
|
72
|
+
│ ├── tokens/ # Дизайн-токены (--nc-*)
|
|
73
|
+
│ │ ├── color.css
|
|
74
|
+
│ │ ├── type.css
|
|
75
|
+
│ │ ├── space.css
|
|
76
|
+
│ │ ├── radius.css
|
|
77
|
+
│ │ ├── shadow.css
|
|
78
|
+
│ │ ├── motion.css
|
|
79
|
+
│ │ ├── z.css
|
|
80
|
+
│ │ └── breakpoint.css
|
|
81
|
+
│ ├── base/ # Базовые стили элементов
|
|
82
|
+
│ │ ├── elements.css
|
|
83
|
+
│ │ ├── forms.css
|
|
84
|
+
│ │ └── media.css
|
|
85
|
+
│ ├── layout/ # Layout-примитивы
|
|
86
|
+
│ │ ├── container.css
|
|
87
|
+
│ │ ├── grid.css
|
|
88
|
+
│ │ ├── stack.css
|
|
89
|
+
│ │ ├── cluster.css
|
|
90
|
+
│ │ ├── sidebar.css
|
|
91
|
+
│ │ ├── switcher.css
|
|
92
|
+
│ │ ├── cover.css
|
|
93
|
+
│ │ └── frame.css
|
|
94
|
+
│ ├── utilities/ # Утилитарные классы
|
|
95
|
+
│ │ ├── display.css
|
|
96
|
+
│ │ ├── flex.css
|
|
97
|
+
│ │ ├── spacing.css
|
|
98
|
+
│ │ ├── sizing.css
|
|
99
|
+
│ │ ├── typography.css
|
|
100
|
+
│ │ ├── color.css
|
|
101
|
+
│ │ ├── border.css
|
|
102
|
+
│ │ ├── shadow.css
|
|
103
|
+
│ │ ├── position.css
|
|
104
|
+
│ │ ├── overflow.css
|
|
105
|
+
│ │ ├── interaction.css
|
|
106
|
+
│ │ └── a11y.css
|
|
107
|
+
│ ├── themes/ # Опциональные переопределения [data-theme]
|
|
108
|
+
│ │ ├── light.css
|
|
109
|
+
│ │ └── dark.css
|
|
110
|
+
│ └── legacy/ # SCSS-ядро NightVue (только как референс)
|
|
111
|
+
├── scripts/
|
|
112
|
+
│ └── build.mjs # Сборка Lightning CSS
|
|
113
|
+
├── tests/
|
|
114
|
+
│ ├── size.mjs # Проверка бюджета размера
|
|
115
|
+
│ └── layer-order.mjs # Проверка порядка слоёв и отсутствия !important
|
|
116
|
+
├── package.json
|
|
117
|
+
├── LICENSE
|
|
118
|
+
├── README.md
|
|
119
|
+
└── README.ru.md
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Начало работы
|
|
123
|
+
|
|
124
|
+
### Требования
|
|
125
|
+
|
|
126
|
+
- [Node.js](https://nodejs.org/) `>=18` (только для сборки — у NightCSS нет рантайм-зависимостей).
|
|
127
|
+
|
|
128
|
+
### Установка
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
git clone https://github.com/nightrunner91/nightcss.git
|
|
132
|
+
cd nightcss
|
|
133
|
+
npm install
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Быстрый старт
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
npm run build
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Это запишет собранный CSS в `dist/`, включая полный бандл (`nightcss.css`) и минифицированные модули.
|
|
143
|
+
|
|
144
|
+
## Использование
|
|
145
|
+
|
|
146
|
+
Подключите собранный стиль к странице:
|
|
147
|
+
|
|
148
|
+
```html
|
|
149
|
+
<link rel="stylesheet" href="dist/nightcss.css">
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Или установите из npm и импортируйте:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
npm install nightcss
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
```css
|
|
159
|
+
@import "nightcss";
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Отдельные модули тоже экспортируются:
|
|
163
|
+
|
|
164
|
+
```css
|
|
165
|
+
@import "nightcss/reset";
|
|
166
|
+
@import "nightcss/tokens";
|
|
167
|
+
@import "nightcss/base";
|
|
168
|
+
@import "nightcss/layout";
|
|
169
|
+
@import "nightcss/utilities";
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Sass-сабпак
|
|
173
|
+
|
|
174
|
+
NightCSS также поставляет опциональный Sass-сабпак (`nightcss/scss`) для проектов на SCSS: карты токенов, функции-аксессоры `var(--nc-*)`, цветовые хелперы на `color-mix(in oklch)` и несколько небольших миксинов — всё на современной модульной системе (`@use`/`@forward`, `sass:map`, без `!important`, без `@import`).
|
|
175
|
+
|
|
176
|
+
```scss
|
|
177
|
+
@use "nightcss/scss" as nc;
|
|
178
|
+
|
|
179
|
+
.card {
|
|
180
|
+
padding: nc.nc-space(4);
|
|
181
|
+
border-radius: nc.nc-radius("md");
|
|
182
|
+
box-shadow: nc.nc-shadow("md");
|
|
183
|
+
color: nc.nc-color("text");
|
|
184
|
+
background: nc.nc-tint(nc.nc-color("accent"), 92%);
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
Карты токенов тоже реэкспортируются для доступа на этапе компиляции: `map.get(nc.$nc-space, 4)` → `1rem`.
|
|
189
|
+
|
|
190
|
+
Это всё — NightCSS не требует ни JavaScript, ни настройки бандлера.
|
|
191
|
+
|
|
192
|
+
## Конфигурация
|
|
193
|
+
|
|
194
|
+
NightCSS настраивается исключительно через CSS custom properties. Переопределите любой токен на `:root`, чтобы сменить тему фундамента в рантайме:
|
|
195
|
+
|
|
196
|
+
```css
|
|
197
|
+
:root {
|
|
198
|
+
--nc-accent: oklch(45% 0.2 280);
|
|
199
|
+
--nc-radius-md: 0.75rem;
|
|
200
|
+
--nc-space-4: 1.25rem;
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
| Группа | Токены |
|
|
205
|
+
|---|---|
|
|
206
|
+
| Цвет | `--nc-accent`, `--nc-accent-contrast`, `--nc-surface`, `--nc-surface-raised`, `--nc-text`, `--nc-text-muted`, `--nc-border`, `--nc-ring` |
|
|
207
|
+
| Типографика | `--nc-font-sans`, `--nc-font-mono`, `--nc-text-xs`…`--nc-text-4xl`, `--nc-leading-*`, `--nc-tracking-*`, `--nc-weight-*` |
|
|
208
|
+
| Отступы | `--nc-space-0`…`--nc-space-24` (шаг 4px) |
|
|
209
|
+
| Радиусы | `--nc-radius-none`, `--nc-radius-sm`, `--nc-radius-md`, `--nc-radius-lg`, `--nc-radius-xl`, `--nc-radius-full` |
|
|
210
|
+
| Тени | `--nc-shadow-xs`, `--nc-shadow-sm`, `--nc-shadow-md`, `--nc-shadow-lg` |
|
|
211
|
+
| Движение | `--nc-duration-fast`, `--nc-duration-base`, `--nc-duration-slow`, `--nc-ease-standard`, `--nc-ease-emphasized` |
|
|
212
|
+
| Z-index | `--nc-z-base`, `--nc-z-dropdown`, `--nc-z-sticky`, `--nc-z-overlay`, `--nc-z-modal`, `--nc-z-toast` |
|
|
213
|
+
|
|
214
|
+
### Escape hatch
|
|
215
|
+
|
|
216
|
+
Каждая scale-утилита читает короткую custom property с фолбэком на токен, поэтому произвольные значения работают инлайн, без сборки:
|
|
217
|
+
|
|
218
|
+
```html
|
|
219
|
+
<div class="p-4" style="--p: 37px">
|
|
220
|
+
<div class="w-4" style="--w: 12rem"></div>
|
|
221
|
+
</div>
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
| Семейство | Переменная |
|
|
225
|
+
|---|---|
|
|
226
|
+
| Отступы (`p-*`, `px-*`, `py-*`) | `--p` |
|
|
227
|
+
| Внешние отступы (`m-*`, `mx-*`, `my-*`) | `--m` |
|
|
228
|
+
| Промежутки (`gap-*`) | `--gap` |
|
|
229
|
+
| Вертикальный ритм (`space-y-*`) | `--space-y` |
|
|
230
|
+
| Ширина / высота (`w-*`, `h-*`) | `--w`, `--h` |
|
|
231
|
+
| Min/max размеры | `--min-w`, `--max-w`, `--min-h` |
|
|
232
|
+
| Радиус скругления (`rounded-*`) | `--radius` |
|
|
233
|
+
| Размер шрифта (`text-*`) | `--text-size` |
|
|
234
|
+
| Тень (`shadow-*`) | `--shadow` |
|
|
235
|
+
|
|
236
|
+
### Темизация
|
|
237
|
+
|
|
238
|
+
Тема автоматически следует за `color-scheme` операционной системы через `light-dark()`. Чтобы принудительно задать тему, установите атрибут `data-theme` и импортируйте соответствующее переопределение:
|
|
239
|
+
|
|
240
|
+
```html
|
|
241
|
+
<html data-theme="dark">
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
```css
|
|
245
|
+
@import "nightcss/themes/dark";
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
## План развития
|
|
249
|
+
|
|
250
|
+
- **`0.1.0-alpha.0` (текущая)** — токены, сброс, базовые стили, темизация, утилиты, layout-примитивы и Sass-сабпак.
|
|
251
|
+
- **Далее** — сайт документации и гайды по нативным паттернам (`<dialog>`, `popover`, `<details>`, `:has()`).
|
|
252
|
+
- **Позже** — заморозка API в `1.0.0` и публикация.
|
|
253
|
+
|
|
254
|
+
## Разработка
|
|
255
|
+
|
|
256
|
+
### Доступные скрипты
|
|
257
|
+
|
|
258
|
+
| Команда | Описание |
|
|
259
|
+
|---|---|
|
|
260
|
+
| `npm run build` | Собрать и минифицировать CSS в `dist/` |
|
|
261
|
+
| `npm run lint` | Проверить исходный CSS через Stylelint |
|
|
262
|
+
| `npm test` | Запустить тесты размера, порядка слоёв и Sass |
|
|
263
|
+
| `npm run test:size` | Проверить бюджет размера в gzip |
|
|
264
|
+
| `npm run test:layers` | Проверить порядок слоёв, отсутствие `!important` и дублей селекторов |
|
|
265
|
+
| `npm run test:scss` | Скомпилировать Sass-сабпак и убедиться, что он осовременен |
|
|
266
|
+
|
|
267
|
+
### Запуск тестов
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
npm test
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
Набор проверяет, что ядро остаётся в пределах 8 KB gzip, полный бандл — в пределах 25 KB gzip, а порядок слоёв, гарантия отсутствия `!important` и отсутствие дублей селекторов соблюдаются в собранном выводе.
|
|
274
|
+
|
|
275
|
+
## Участие в разработке
|
|
276
|
+
|
|
277
|
+
Мы приветствуем вклад в развитие проекта. Пожалуйста, сначала откройте issue, чтобы обсудить желаемые изменения.
|
|
278
|
+
|
|
279
|
+
1. Сделайте форк проекта.
|
|
280
|
+
2. Создайте ветку для новой функции.
|
|
281
|
+
3. Зафиксируйте изменения.
|
|
282
|
+
4. Отправьте изменения в ветку.
|
|
283
|
+
5. Откройте pull request.
|
|
284
|
+
|
|
285
|
+
## Лицензия
|
|
286
|
+
|
|
287
|
+
Этот проект распространяется под лицензией [MIT](LICENSE).
|
|
288
|
+
|
|
289
|
+
---
|
|
290
|
+
|
|
291
|
+
<p align="center">
|
|
292
|
+
Сделано с ❤ <a href="https://t.me/nightrunner91">nightrunner91</a>
|
|
293
|
+
</p>
|