Skip to content

Commit

Permalink
Merge pull request #9 from kylejrp/master
Browse files Browse the repository at this point in the history
Add Sass build tools and theming
  • Loading branch information
kognise committed Apr 6, 2019
2 parents 703abfc + 50ee6a0 commit 12f8b79
Show file tree
Hide file tree
Showing 19 changed files with 3,173 additions and 199 deletions.
84 changes: 84 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/
98 changes: 82 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
[![On product hunt](https://img.shields.io/badge/on-product%20hunt-red.svg)](https://www.producthunt.com/posts/water-css)
[![MIT license](https://img.shields.io/github/license/kognise/water.css.svg)](https://github.com/kognise/water.css/blob/master/LICENSE.md)

## Goals

- Responsive
- Good code quality
- Good browser support (works on my old kindle's browser :P)
- Small size (< 2kb)
- Beautiful
- No classes

## Why?

I commonly make quick demo pages or websites with simple content. For these, I don't want to spend time styling them but don't like the uglyness of the default styles.
Expand All @@ -25,36 +34,93 @@ You probably don't want to use it for a production app or something that has mor
Just stick this in your head:

```html
<link rel='stylesheet' href='https://cdn.jsdelivr.net/gh/kognise/water.css@latest/water.min.css'>
<link rel='stylesheet' href='https://cdn.jsdelivr.net/gh/kognise/water.css@latest/dist/dark.css'>
```

No other classes or code is required to make Water.css work. If you want a specific version, you can replace `@latest` with `@version`. See [all versions](https://github.com/kognise/water.css/releases).
Well, there's a dark theme and a light theme. If you want the light theme, use `light.css` instead of `dark.css`. See [Theming](#theming) to make your own theme!

Well, I may have lied a *little* bit when I said Water.css makes use of no classes: if you're a light theme guy (shame on you!) just add the class `.light` to your `<body>` and everything will burn your eyes.
No other classes or code is required to make Water.css work. If you want a specific version, you can replace `@latest` with `@version`. See [all the versions](https://github.com/kognise/water.css/releases).

Oh, you want a demo you say? Cheeky fellah!

[Well, here's your demo.](https://kognise.github.io/water.css/) And here's a screenshot of the dark theme to top it off:

![Screenshot](screenshot.jpg)
[Well, here's your demo.](https://kognise.github.io/water.css/)

Don't like how it looks? Feel free to submit an issue or PR with suggestions.

## Contributing

Water.css can be greatly improved if people in the community help make it better!
Water.css becomes better for everyone when people like you help make it better!

Have any questions or concerns? Did I forget an element or selector? Does something look ugly? Feel free to submit an issue or pull request.

If you decide to cotnribute, after downloading a copy of the repository make sure to run `yarn` to install dependencies useful for development. Then, you can just run the following to start a server of the demo with live reloading and automatic Sass compiling.

```
$ yarn dev
```

And make sure to run `yarn build` before pushing any changes! Thanks for taking the time to contribute :)

## Theming

Do you want to make your own theme different from the light or dark themes? Since Water.css is built with Sass this is super easy to do. There are two methods. Also, here's a list of variables to set:

- `$background`
- `$background-alt`
- `$text-main`
- `$text-bright`
- `$links`
- `$focus`
- `$border`
- `$code`
- `$button-hover`
- `$animation-duration`
- `$form-placeholder`
- `$form-text`

### Based on an existing theme

You can base your theme off of the existing light or dark themes, which already have some variables predefined to make it easier for you.

Have any questions or concerns? Did I forget an element or selector? Does something look ugly? Feel free to submit an issue.
Here's some simple Sass that'll just use the dark theme but color all links red. Of course, you can change any variables you want.

```scss
$links: #ff0000;
@import 'dark.scss';
```

### From scratch

You can also make your theme from scratch. This is less recommended, but feel free to! You just have to define all of the variables.

For example, here's an example of a really ugly theme, made from scratch. **Ouch!**

```scss
$background: #ff48c2 !default;
$background-alt: #00ff00 !default;

$text-main: #dbdbdb !default;
$text-bright: #ffffff !default;

$links: #ff0022 !default;
$focus: #ffc400 !default;
$border: #00ffff !default;
$code: #001aff !default;

$button-hover: #324759 !default;
$animation-duration: 0.1s !default;

$form-placeholder: #a9a9a9 !default;
$form-text: #ffffff !default;

@import 'parts/core';
```

You can also only import parts you want, but this is not recommended. See the `src/parts/` folder for a list of parts.

## Todos

- Animate more things
- Reduce size
- [Tables](https://github.com/kognise/water.css/issues/5)
- Blockquotes
- Update screenshots
- Jekyll theme
- [Code/kbd/blocks](https://github.com/kognise/water.css/issues/1)
- [Code splitting](https://github.com/kognise/water.css/issues/6)

Feel free to help! :P
- Add a screenshot
- Jekyll theme
75 changes: 75 additions & 0 deletions dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
const express = require('express')
const app = express()
const http = require('http').Server(app)
const io = require('socket.io')(http)
const fs = require('fs-extra')
const chokidar = require('chokidar')
const sass = require('node-sass')

const script = `
const socket = io()
socket.on('reload', () => location.reload())
`

app.get('/', async (req, res) => {
console.log('> Serving index')
const html = await fs.readFile('index.html')
const injected = html.toString().replace('</body>', `<script src='/socket.io/socket.io.js'></script><script>${script}</script></body>`)
res.send(injected)
})

app.get('/script.js', async (req, res) => {
console.log('> Serving script')
const script = await fs.readFile('script.js')
res.contentType('javascript')
res.send(script)
})

app.use('/dist', (req, res, next) => {
console.log('> Serving a stylesheet')
next()
}, express.static('dist'))

function reload() {
console.log('> Reloading')
io.emit('reload')
}

chokidar.watch('index.html', { ignoreInitial: true }).on('all', () => {
console.log('> Index changed')
reload()
})

chokidar.watch('script.js', { ignoreInitial: true }).on('all', () => {
console.log('> Script changed')
reload()
})

function buildSass(file) {
sass.render({ file, outputStyle: 'compressed' }, async (errors, result) => {
if (errors) {
console.log('> Sass errors!')
console.log(errors)
return
}
const outFile = file.replace('src', 'dist').replace('.scss', '.css')
await fs.outputFile(outFile, result.css)
reload()
})
}

chokidar.watch('src/*.scss', { ignoreInitial: true }).on('all', (event, file) => {
console.log('> Stylesheet changed')
buildSass(file)
})

chokidar.watch('src/parts/*.scss', { ignoreInitial: true }).on('all', async () => {
console.log('> Stylesheet part changed')
const src = await fs.readdir('src')
const files = src.filter(file => file !== 'parts').map(file => `src/${file}`)
for (let file of files) {
buildSass(file)
}
})

http.listen(3000, () => console.log('> Ready at http://localhost:3000/'))
1 change: 1 addition & 0 deletions dist/dark.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/light.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 12f8b79

Please sign in to comment.