mirror of
https://github.com/kognise/water.css.git
synced 2025-08-21 04:11:30 +02:00
Add NPM installation instructions and update goals (#221)
This commit is contained in:
32
README.md
32
README.md
@@ -16,12 +16,13 @@
|
||||
|
||||
## Goals
|
||||
|
||||
- Responsive
|
||||
- Themeable
|
||||
- Good browser support (works on my old kindle's browser :P)
|
||||
- Tiny size
|
||||
- Beautiful
|
||||
- No classes
|
||||
- It's responsive
|
||||
- It's easy to theme
|
||||
- It has great browser support
|
||||
- It has a tiny size
|
||||
- It doesn't require **any** classes
|
||||
- It looks beautiful
|
||||
- It encourages semantic code
|
||||
|
||||
## Why?
|
||||
|
||||
@@ -55,6 +56,25 @@ Just stick this in your `<head>`:
|
||||
|
||||
A **preview** of the different themes is available [on the **demo page**](https://watercss.kognise.dev/#installation)! ⚡
|
||||
|
||||
#### Installing from NPM
|
||||
|
||||
Alternatively, to install Water.css through a package manager, you can run:
|
||||
|
||||
```sh
|
||||
# Using NPM
|
||||
npm install water.css
|
||||
# Using Yarn
|
||||
yarn add water.css
|
||||
```
|
||||
|
||||
In JavaScript, where CSS imports are supported:
|
||||
|
||||
```js
|
||||
import 'water.css/out/water.css'
|
||||
```
|
||||
|
||||
Usage from CSS depends on your bundler and dependency management setup, but in some cases may be as simple as a `@import`.
|
||||
|
||||
#### How the "Automatic Theme" works
|
||||
|
||||
The main `water.css` file automatically switches between light and dark mode depending on the system preferences of a user's device. This detection is made possible through a CSS media query called [`prefers-color-scheme`](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme). In browsers where the preference can't be detected, `water.css` will stick to the light theme.
|
||||
|
@@ -165,6 +165,11 @@
|
||||
<th scope="row">Theme</th>
|
||||
<td id="table-theme"></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th scope="row">NPM instructions</th>
|
||||
<td id="table-npm"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
@@ -17,7 +17,8 @@ const linkSnippets = [...document.querySelectorAll('#link-snippet-container > pr
|
||||
const table = {
|
||||
fileName: document.getElementById('table-file-name'),
|
||||
fileSize: document.getElementById('table-file-size'),
|
||||
theme: document.getElementById('table-theme')
|
||||
theme: document.getElementById('table-theme'),
|
||||
npm: document.getElementById('table-npm')
|
||||
}
|
||||
|
||||
const prefersColorScheme = window.matchMedia('(prefers-color-scheme: light)')
|
||||
@@ -55,6 +56,15 @@ const updateTheme = () => {
|
||||
updateProductHunt(theme)
|
||||
table.theme.innerText = `Theme is forced to ${theme}.`
|
||||
}
|
||||
|
||||
table.npm.innerHTML = `
|
||||
Install with <code>npm i water.css</code> or <code>yarn add water.css</code>.
|
||||
<br><br>
|
||||
In JavaScript, where CSS imports are supported:<br>
|
||||
<code>import 'water.css/out/${fileName}'</code>
|
||||
<br><br>
|
||||
Usage from CSS depends on your bundler and dependency management setup, but in some cases may be as simple as a <code>@import</code>.
|
||||
`
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user