You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Rename @block-reference to @block
- Default @block imports from a Block module.
- Named @block imports from a Block module.
- Default Block exports from a module.
- Named Block exports from a module.
- default as a reserved name.
- Introduced simple parser for import/export parsing.
- Split apart parser tests into logical packages.
Copy file name to clipboardExpand all lines: README.md
+13-13
Original file line number
Diff line number
Diff line change
@@ -111,7 +111,7 @@ CSS Blocks is under active development and there are a number of features that h
111
111
| ❌ | <code>[state|name=value]</code> | Bare state (not associated with an Originating Element) and optional substate selectors for targeting all elements in the Block that possess the state an/or sub-state. |
112
112
| 🖌 | <code>.class[state|name default]</code> | Default state value to be applied when there is no other match. |
113
113
|**At Rules**||
114
-
| ✅ |`@block-reference local-name from "./file/path.css"`| Reference another Block using a local name. |
114
+
| ✅ |`@block local-name from "./file/path.css"`| Reference another Block using a local name. |
115
115
| ✅ |`@block-debug block-name to channel`| Debug call that will print a block interface to a "channel": `comment`, `stderr`, or `stdout`. |
116
116
| ✅ |`@block-global block.path`| Declare a Block class or state as public. It may be used as a context selector in other Blocks. |
117
117
| 🖌 |`@is-block block-name`| Block class can declare itself to be the root of another block in a specific state or set of states. |
@@ -296,14 +296,14 @@ There are only two (2) common-sense rules to follow when using Block styles in y
296
296
# 🏗 Block Composition
297
297
Blocks styles are, by design, scoped to the file they are written in, but we all know that in a real app your styles can't live in a vacuum!
298
298
299
-
As you'll see below, there are many methods to compose blocks together in your application. However, most of these methods will begin with the humble `@block-reference`.
299
+
As you'll see below, there are many methods to compose blocks together in your application. However, most of these methods will begin with the humble `@block`.
300
300
301
301
## Block References
302
-
A Block may declare a dependency on another Block by using a `@block-reference` at the top of your file. A `@block-reference` creates a locally scoped alias where you can access the public API (declared classes and states) of the referenced block.
302
+
A Block may declare a dependency on another Block by using a `@block` at the top of your file. A `@block` creates a locally scoped alias where you can access the public API (declared classes and states) of the referenced block.
303
303
304
304
Block references don't cause any styles to be included. Instead, they are like an ES6 `import` statement -- they make it possible to refer to the public interface of another Block from within the current Block.
305
305
306
-
Adding a `@block-reference` is as simple as this:
306
+
Adding a `@block` is as simple as this:
307
307
308
308
```css
309
309
/* block-1.block.css */
@@ -314,14 +314,14 @@ Adding a `@block-reference` is as simple as this:
314
314
315
315
```css
316
316
/* block-2.block.css */
317
-
@block-reference other-block from "./block-1.block.css";
> Whether you're integrating with a 3rd party library, or pulling in dependencies internal to your company, at some point you'll want to integrate with styles delivered via NPM! The resolution logic for `@block-reference`s to `node_modules` hasn't yet been implemented yet, but you can track progress (or even help out!) [over on Github](https://github.com/linkedin/css-blocks/issues/112).
324
+
> Whether you're integrating with a 3rd party library, or pulling in dependencies internal to your company, at some point you'll want to integrate with styles delivered via NPM! The resolution logic for `@block`s to `node_modules` hasn't yet been implemented yet, but you can track progress (or even help out!) [over on Github](https://github.com/linkedin/css-blocks/issues/112).
325
325
326
326
With the above code, `block-2` now has a local reference `other-block` which points to `block-1`. We can now freely use the `other-block` identifier inside of `block-2` when we want to reference reference `block-1`. This comes in handy! Especially with features like:
327
327
@@ -341,7 +341,7 @@ You do this via the special `implements` property in a Block's `:scope` selector
341
341
342
342
```css
343
343
/* block-2.block.css */
344
-
@block-reference other-block from "./block-1.block.css";
344
+
@block other-block from "./block-1.block.css";
345
345
346
346
:scope {
347
347
block-name: block-2;
@@ -363,7 +363,7 @@ For the build to pass, we need to implement the *full public interface* of `bloc
363
363
364
364
```css
365
365
/* block-2.block.css */
366
-
@block-reference other-block from "./block-1.block.css";
366
+
@block other-block from "./block-1.block.css";
367
367
368
368
:scope {
369
369
block-name: block-2;
@@ -403,7 +403,7 @@ Instead, we can simply extend the `<basic-form>` Block, and only apply the small
403
403
404
404
```css
405
405
/* danger-form.block.css */
406
-
@block-reference basic-form from "./basic-form.block.css";
406
+
@block basic-form from "./basic-form.block.css";
407
407
408
408
:scope { extends: basic-form; }
409
409
.button { background-color: darkred; }
@@ -465,7 +465,7 @@ Block Paths take the form:
465
465
block.class[state|name='value']
466
466
```
467
467
468
-
All sections of this selector – except the leading Block name – are optional. The leading Block name *must* refer to an imported `@block-reference` at the top of the file. If css-blocks is unable to resolve a Block Path at build time, you will get a friendly error message in your console!
468
+
All sections of this selector – except the leading Block name – are optional. The leading Block name *must* refer to an imported `@block` at the top of the file. If css-blocks is unable to resolve a Block Path at build time, you will get a friendly error message in your console!
469
469
470
470
All the following syntaxes are legal to select any given stylable on a referenced Block:
471
471
@@ -509,7 +509,7 @@ For Glimmer, using multiple blocks in a single template will look something like
509
509
510
510
```css
511
511
/* stylesheet.css */
512
-
@block-reference other from "./hoverable.css";
512
+
@block other from "./hoverable.css";
513
513
514
514
:scope { block-name: main; }
515
515
.form {
@@ -679,7 +679,7 @@ So, for the following two Blocks where `my-class-1[state|enabled]` and `my-class
679
679
```css
680
680
/* main.css */
681
681
682
-
@block-reference other from "./other.css";
682
+
@block other from "./other.css";
683
683
684
684
.my-class-2::before {
685
685
border-width: 2px;
@@ -724,7 +724,7 @@ This is most useful for global application states – like during initial applic
724
724
```css
725
725
/* navigation.block.css */
726
726
727
-
@block-reference app from "application.block.css";
Copy file name to clipboardExpand all lines: packages/@css-blocks/core/README.md
+6-6
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@
12
12
|**rootDir**|`process.cwd()`| The root directory from which all sources are relative. |
13
13
|**outputMode**|`"BEM"`| Block file output mode. One of [OutputMode][OUTPUT_MODE]|
14
14
|**preprocessors**|`{}`| A preprocessor function can be declared by [Syntax][SYNTAX]. |
15
-
|**importer**|[`FilesystemImporter`](./src/importing/FilesystemImporter.ts)| A custom importer to resolve identifiers passed to `@block-reference`. |
15
+
|**importer**|[`FilesystemImporter`](./src/importing/FilesystemImporter.ts)| A custom importer to resolve identifiers passed to `@block`. |
16
16
|**importerData**|`{}`| Additional data to make available to the importer. |
17
17
|**maxConcurrentCompiles**|`4`| Limits block parsing and compilation to this number of threads at any one time. |
18
18
|**disablePreprocessChaining**|`false`| If a preprocessor function is declared for `css`, all blocks will be ran through it, even those that were pre-processed for another syntax. This can be disabled by setting `disablePreprocessChaining` to true. |
@@ -39,7 +39,7 @@ Container Nodes...contain other nodes ;) These nodes contain logical groupings o
39
39
#### Block
40
40
A `Block` node is always the root of any `BlockTree`. A `Block` may be parent to any number of `BlockClass`es. The `:scope` selector is considered a special kind of `BlockClass` selector and is also stored as a child of `Block`.
41
41
42
-
`Block` nodes also store all data related to any `@block-reference`s, the `block-name`, implemented `Blocks`, the inherited `Block`, and any other metadata stored in the Block file. `Block`s also have a special `rootClass` property that points directly to the child `BlockClass` that represents the parsed `:scope` selector .
42
+
`Block` nodes also store all data related to any `@block`s, the `block-name`, implemented `Blocks`, the inherited `Block`, and any other metadata stored in the Block file. `Block`s also have a special `rootClass` property that points directly to the child `BlockClass` that represents the parsed `:scope` selector .
43
43
44
44
#### Attribute
45
45
An `Attribute` node represents a single unique attribute `namespace|name` pair and is a parent to any number of `AttrValue` nodes, which represent all the possible attribute values for this `Attribute` discovered in the Block file. An `Attribute` node's parent is always a `BlockClass`. Attribute selectors where no value is specified are considered a special kind of `AttrValue` and is also stored as a child of `Attribute`.
@@ -80,7 +80,7 @@ Block compilation becomes a little more complicated once we begin emitting confl
@@ -196,9 +196,9 @@ The **configuration** package contains the CSS Blocks build configuration utilit
196
196
See the options table at the top of this file for configuration object details.
197
197
198
198
## /src/importing
199
-
CSS Blocks needs to know where to get a Block file's contents when provided a file `FileIdentifier` from an `@block-reference`. Most of the time, this file path will be a file on disk, in which case the default importer delivered with CSS Blocks will work out of the box. However, in cases where custom resolution of `@block-reference`s are required, consumers are able to provide their own implementation of the CSS Blocks `Importer` interface to deliver this custom behavior.
199
+
CSS Blocks needs to know where to get a Block file's contents when provided a file `FileIdentifier` from an `@block`. Most of the time, this file path will be a file on disk, in which case the default importer delivered with CSS Blocks will work out of the box. However, in cases where custom resolution of `@block`s are required, consumers are able to provide their own implementation of the CSS Blocks `Importer` interface to deliver this custom behavior.
200
200
201
-
A custom importer may be passed to CSS Blocks via the `importer` options of the configuration object. Custom importers will understand how to resolve information about the `FileIdentifier` passed to `@block-reference` and are used to abstract application or platform specific path resolution logic.
201
+
A custom importer may be passed to CSS Blocks via the `importer` options of the configuration object. Custom importers will understand how to resolve information about the `FileIdentifier` passed to `@block` and are used to abstract application or platform specific path resolution logic.
202
202
203
203
Any CSS Blocks `Importer`**must** implement the interface defined for a CSS Blocks `Importer` in [`/src/importing/types.ts`](./src/importing/types.ts). Every importer is required to have a number of introspection methods that return standard metadata for a given `FileIdentifier`:
204
204
@@ -214,7 +214,7 @@ For any custom importers that require extra data to be passed by the end-user, t
214
214
215
215
CSS Blocks ships with two (2) pre-defined importers.
216
216
217
-
1.`FilesystemImporter`: This is the default importer used by CSS Blocks if no other is provided. It enables `@block-reference`s to resolve relative and absolute file references
217
+
1.`FilesystemImporter`: This is the default importer used by CSS Blocks if no other is provided. It enables `@block`s to resolve relative and absolute file references
218
218
2.`PathAliasImporter`: The PathAliasImporter is a replacement for the fileystem importer. Relative import paths are first checked to see if they match an existing file relative to the from identifier (when provided). Then if the relative import path has a first segment that is any of the aliases provided the path will be made absolute using that alias's path location. Finally any relative path is resolved against the `rootDir` specified in the CSS Block configuration options.
0 commit comments