Skip to content

Commit

Permalink
readme corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
evnp committed Feb 7, 2024
1 parent 344e93f commit 601e760
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
22 changes: 22 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
MIT License

Copyright (c) 2019 Evan Campbell Purcer

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ The missing, well-typed link between HTML and CSS.
\/_/ \/_/ \/_____/ \/_____/ namespace.style
```

[![latest release](https://img.shields.io/github/release/evnp/namespace.style.svg)](https://github.com/evnp/namespace.style/releases/latest)
[![npm package](https://img.shields.io/npm/v/namespace.style.svg)](https://www.npmjs.com/package/namespace.style)
[![license](https://img.shields.io/github/license/evnp/namespace.style.svg?color=blue)](https://github.com/evnp/namespace.style/blob/master/LICENSE.md)

- Make element class names type-safe, typo-free, and autocompletable.
- Make debugging DOM a dream – give everything a name you can actually understand. No generated hex soup.
Expand Down Expand Up @@ -108,7 +106,7 @@ import { css } from "astroturf";
import { defineComponent } from "vue";
```
First we import the `nss` module as well as necessary Astroturf and Vue functions.
First we import the `nss` module as well as necessary [Astroturf](https://github.com/astroturfcss/astroturf) and Vue functions.
```typescript
// Enums define available NSS elememt classes, and provide a "map" of component
Expand Down Expand Up @@ -209,15 +207,15 @@ export const n = nss<typeof Name, typeof Elem, typeof Cond>(Name, Elem, Cond, ()
return { SpecialList, Item, Ordered, Inline };
});
```
Finally, we have our CSS-in-JS setup using Astroturf. The NSS class management system can be used _without_ CSS-in-JS, in which case the NSS declaration would look much simpler:
Finally, we have our CSS-in-JS setup using [Astroturf](https://github.com/astroturfcss/astroturf). The NSS class management system can be used _without_ CSS-in-JS, in which case the NSS declaration would look much simpler:
```typescript
export const n = nss<typeof Name, typeof Elem, typeof Cond>(Name, Elem, Cond);
```
You'd use the `n` object in the exact same way in your template code. In this shorter case, it would probably make sense to place `const n` at the top of the file, next to the NSS enums. In the CSS-in-JS case however, it's ergonomic to place all component styles at the end of the file. `const n` is hoisted to the top in both cases, so it doesn't actually matter – you'll be able to use `n` in your templates wherever you put `const nss`.
We `export const n` here so that it can be imported in test code as a type-aware source of element selectors. The export is only necessary if you want to use NSS externally from the component though.
There are many ways to map styles to NSS elements. The function which we're passing to `nss` above is one way – Astroturf generates vars containing unique class strings within it, and we return a mapping of NSS keys to these unique class strings. Instead of a function, you could also pass a simple object mapping here, or you could just use NSS classes directly within your styles – they're extremely human-readable.
There are many ways to map styles to NSS elements. The function which we're passing to `nss` above is one way – [Astroturf](https://github.com/astroturfcss/astroturf) generates vars containing unique class strings within it, and we return a mapping of NSS keys to these unique class strings. Instead of a function, you could also pass a simple object mapping here, or you could just use NSS classes directly within your styles – they're extremely human-readable.
More docs are coming soon, until then please refer to NSS's extensive test cases for more usage examples:
https://github.com/evnp/namespace.style/blob/main/test/nss.test.ts
Expand Down

0 comments on commit 601e760

Please sign in to comment.