Skip to content

Commit 1cca1c4

Browse files
authored
Merge pull request #19 from chris-pearce/v1
Version 1 🕺
2 parents d2a754b + c2679e3 commit 1cca1c4

24 files changed

Lines changed: 3141 additions & 2 deletions

.editorconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[*]
2+
charset = utf-8
3+
end_of_line = lf
4+
indent_style = space
5+
indent_size = 2
6+
max_line_length = 80
7+
trim_trailing_whitespace = true
8+
9+
[*.md]
10+
trim_trailing_whitespace = false

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Folders and files
2+
node_modules/
3+
lib/
4+
npm-debug.log
5+
yarn-error.log
6+
7+
# Dot files
8+
.cache
9+
.DS_Store
10+
.vscode

.prettierrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"printWidth": 80,
3+
"proseWrap": "never",
4+
"singleQuote": true,
5+
"trailingComma": "es5"
6+
}

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Changes to backpack.css 🎒

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright © Chris Pearce
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.

README.md

Lines changed: 141 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,144 @@
1-
# backpack.css 🎒
1+
# backpack.css 🎒 <!-- omit in toc -->
22

33
A lightweight and somewhat opinionated CSS foundation that is best suited to applications.
44

5-
⚠️ Under development, version 1.0.0 coming soon.
5+
## Table of contents <!-- omit in toc -->
6+
7+
- [Installation](#installation)
8+
- [How to use](#how-to-use)
9+
- [Importing with a bundler](#importing-with-a-bundler)
10+
- [Importing without a bundler](#importing-without-a-bundler)
11+
- [Overriding](#overriding)
12+
- [Motivation](#motivation)
13+
- [What it does](#what-it-does)
14+
- [Evolution](#evolution)
15+
- [Browser support](#browser-support)
16+
- [Publishing](#publishing)
17+
- [The breakdown of step 3](#the-breakdown-of-step-3)
18+
- [Contributing](#contributing)
19+
- [Versioning](#versioning)
20+
21+
## Installation
22+
23+
Run the following command using [npm](https://www.npmjs.com/):
24+
25+
```bash
26+
npm install backpack.css --save-dev
27+
```
28+
29+
If you prefer [Yarn](https://yarnpkg.com/en/), use this command instead:
30+
31+
```bash
32+
yarn add backpack.css --dev
33+
```
34+
35+
CDN version coming soon, [see](https://github.com/chris-pearce/backpack.css/issues/15).
36+
37+
## How to use
38+
39+
Typically you'll be wanting to import all of backpack.css styles into your project but you do have the choice to be selective. The one strict rule is that it must come before your project's CSS to ensure correct ordering of your styles and to be able to override any of backpack.css styles.
40+
41+
### Importing with a bundler
42+
43+
If you're using a bundler such as [webpack](https://webpack.js.org/) and wanting to import all of backpack.css then your projects entry point should look like this:
44+
45+
```js
46+
import 'backpack.css';
47+
import '[path(s)-to-your-project-css]';
48+
```
49+
50+
If you want to be selective then simply `import` the backpack.css files you need, for example:
51+
52+
```js
53+
import 'backpack.css/lib/resets.css';
54+
import 'backpack.css/lib/content-sectioning.css';
55+
import 'backpack.css/lib/forms.css';
56+
import '[path(s)-to-your-project-css]';
57+
```
58+
59+
The order at which you import each module is important, to see this order and what `.css` files are available refer to backpack.css [`index.css`](src/index.css).
60+
61+
### Importing without a bundler
62+
63+
CDN version coming soon, [see](https://github.com/chris-pearce/backpack.css/issues/15). In the meantime you can link to the hosted version on [UNPKG](https://unpkg.com) via a `<link>` element in your HTML Head, however, make sure it comes before your project's CSS.
64+
65+
### Overriding
66+
67+
backpack.css is just CSS so you can easily override any of backpack.css styles just as you would override any CSS, as in, via the rules of the cascade and specificity.
68+
69+
For example, if you don't want to use `system-ui` as the global `font-family` set in [`main-root.css`](src/main-root.css) then simply redeclare it in your project CSS like so:
70+
71+
```css
72+
html {
73+
font-family: serif;
74+
}
75+
```
76+
77+
## Motivation
78+
79+
Nowadays I'm building [React](https://reactjs.org/) applications that have highly componentised User Interfaces (UI) making use of native CSS layout mechanisms such as [Flexbox](https://css-tricks.com/snippets/css/a-guide-to-flexbox/) and [Grid](https://css-tricks.com/snippets/css/complete-guide-grid/). I'm no longer finding the need for heavy handed CSS frameworks that handle most of my UI concerns, especially layout. Instead I build components with a smidgen of global styles.
80+
81+
What I do need, however, are a bunch of smart and sensible foundational styles suited for applications that I would typically forget project to project—think [Normalize.css](http://necolas.github.io/normalize.css/) and then some. Something that is lightweight, super easy to intergrate, and can easily be overriden or allow for modular use, thus giving birth to backpack.css 🙂.
82+
83+
## What it does
84+
85+
- Removes margins, paddings, and borders from all elements except `<input>` so that everything is on an even playing field.
86+
- Applies sensible form element resets and normalisations, e.g.: _remove all user-agent styles from buttons_.
87+
- Makes all images responsive.
88+
- Applies sensible interactive styles, e.g.: _avoid 300ms click delay on touch devices_.
89+
- Applies foundational print styles.
90+
- Applies the nicer `border-box` value to all elements.
91+
- Removes list bullets.
92+
- Applies sensible OpenType features, e.g.: _enables lining numerals, tabular numerals, and slashed zero, for table content_.
93+
94+
_And more…_
95+
96+
## Evolution
97+
98+
This is the third CSS framework/library I've created. Looking at each one lets you see how UI development has evolved over the years with each iteration getting smaller and smaller.
99+
100+
1. [Scally](https://github.com/chris-pearce/scally) _circa 2014_
101+
2. [Shell](https://github.com/campaignmonitor/shell) _circa 2016_
102+
3. [backpack.css](https://github.com/chris-pearce/backpack.css) _circa 2018_
103+
104+
## Browser support
105+
106+
- Chrome
107+
- Edge
108+
- Firefox
109+
- Internet Explorer 11
110+
- Safari 8+
111+
- Opera
112+
113+
Not everything will work in Internet Explorer 11, e.g.: the [`system-ui`](https://caniuse.com/#feat=font-family-system-uiZ) font, however, anything that doesn't work will simply degrade gracefully.
114+
115+
It's recommended to have [Autoprefixer](https://github.com/postcss/autoprefixer) setup as part of your projects build.
116+
117+
## Publishing
118+
119+
Once new changes have been merged do the following:
120+
121+
1. Add all new changes to [`CHANGELOG.md`](CHANGELOG.md) making sure to follow the existing format.
122+
2. Update the version number in [`index.css`](src/index.css).
123+
3. Run: `npm version <update_type>` where `<update_type>` is one of the semantic versioning release types: **patch**, **minor**, or **major** (see [versioning](#versioning)).
124+
125+
### The breakdown of step 3
126+
127+
1. Run the `build` script.
128+
2. Add `CHANGELOG.md` and `index.css` modified in **steps 1** and **2** to the version commit.
129+
3. Change the version number in [`package.json`](package.json).
130+
4. Push the new version commit and tag up to the repository.
131+
5. Clean the `lib` directory.
132+
6. Publish the new version to the NPM registry.
133+
134+
_Each step will only run if the one before it passed._
135+
136+
## Contributing
137+
138+
_`CONTRIBUTING.MD` coming soon, [see](https://github.com/chris-pearce/backpack.css/issues/10)._
139+
140+
## Versioning
141+
142+
backpack.css is maintained under the [Semantic Versioning guidelines](http://semver.org/). We'll do our best to adhere to those guidelines and strive to maintain backwards compatibility.
143+
144+
See the [CHANGELOG](CHANGELOG.md).

package.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"name": "backpack.css",
3+
"main": "lib/backpack.css",
4+
"version": "0.0.0",
5+
"description": "A lightweight and somewhat opinionated CSS foundation that is best suited to applications 🎒.",
6+
"keywords": [
7+
"css",
8+
"css-library",
9+
"css-foundation",
10+
"css-reset",
11+
"css-normalise"
12+
],
13+
"files": [
14+
"lib"
15+
],
16+
"scripts": {
17+
"bundle": "postcss src/index.css -u postcss-import --no-map -o lib/backpack.css",
18+
"clean": "rimraf lib",
19+
"copy": "cp -r src/* lib && rm lib/index.css",
20+
"build": "yarn bundle && yarn copy",
21+
"prebuild": "yarn clean",
22+
"version": "npm run build && git add .",
23+
"postversion": "git push && git push --tags && yarn clean && npm publish"
24+
},
25+
"repository": "[email protected]:chris-pearce/backpack.css.git",
26+
"author": "Chris Pearce <[email protected]>",
27+
"license": "MIT",
28+
"devDependencies": {
29+
"normalize.css": "^8.0.0",
30+
"postcss-cli": "^6.0.0",
31+
"postcss-import": "^12.0.0",
32+
"prettier": "^1.14.3",
33+
"rimraf": "^2.6.2"
34+
}
35+
}

src/content-sectioning.css

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* We scope our heading styles to classes instead of the `<hx>` element selector
3+
* so our styles are not tied to their semantics, i.e., if you want a `<h4>` to
4+
* look like a `<h2>` you can easily do this. All of the heading elements are
5+
* reset to have the same styles as the base copy. See:
6+
* https://medium.com/fed-or-dead/handling-headings-in-a-ui-component-library-2587de93c890
7+
*/
8+
9+
h1,
10+
h2,
11+
h3,
12+
h4,
13+
h5,
14+
h6 {
15+
font-size: inherit;
16+
font-weight: normal;
17+
line-height: inherit;
18+
}

src/forms.css

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
/*
2+
* Override normalize.css's opinionated styles, `line-height` is set to 'normal'
3+
* as that's what most user-agents use. See:
4+
* https://github.com/necolas/normalize.css/issues/694.
5+
*/
6+
7+
button,
8+
input,
9+
optgroup,
10+
select,
11+
textarea {
12+
line-height: normal;
13+
}
14+
15+
/*
16+
* 1. Remove noticeable visual user-agent styles so we have a clean slate.
17+
* 2. Remove rounded corners that iOS applies to all `<input>` buttons.
18+
*/
19+
20+
[type='submit'],
21+
[type='button'],
22+
[type='reset'],
23+
button {
24+
background: transparent; /* 1 */
25+
border: 0; /* 1 */
26+
border-radius: 0; /* 2 */
27+
margin: 0; /* 1 */
28+
padding: 0; /* 1 */
29+
}
30+
31+
/*
32+
* 1. Remove top inner shadow that iOS applies to all textual inputs. ✌︎ Credit
33+
* https://davidwalsh.name/input-shadows-ipad
34+
* 2. Remove padding (mostly 1px) that most user-agents apply to all textual
35+
* inputs.
36+
*/
37+
38+
[type='date'],
39+
[type='datetime-local'],
40+
[type='email'],
41+
[type='month'],
42+
[type='number'],
43+
[type='password'],
44+
[type='search'],
45+
[type='tel'],
46+
[type='text'],
47+
[type='time'],
48+
[type='url'],
49+
[type='week'] {
50+
background-clip: padding-box; /* 1 */
51+
padding: 0; /* 2 */
52+
}
53+
54+
/*
55+
* Disable horizontal resizing.
56+
*/
57+
58+
textarea {
59+
resize: vertical;
60+
}
61+
62+
/**
63+
* Override a `<fieldset>`s default `min-width: min-content;` with the more
64+
* standard `min-width: 0;` so it renders as a block element would.
65+
*
66+
* ✌︎ Credit https://thatemil.com/blog/2015/01/03/reset-your-fieldset.
67+
*/
68+
69+
fieldset {
70+
min-width: 0;
71+
}
72+
73+
body:not(:-moz-handler-blocked) fieldset {
74+
display: table-cell;
75+
}
76+
77+
/**
78+
* Remove the clear field button (an "X" icon) and the reveal password button
79+
* (an "eye" icon) that is generated by IE 10+ for textual inputs. See:
80+
* http://stackoverflow.com/a/21869433/1116204.
81+
*/
82+
83+
::-ms-clear,
84+
::-ms-reveal {
85+
display: none;
86+
}
87+
88+
/**
89+
* Un-style the caret for `<select>` lists in IE 10+.
90+
*/
91+
92+
::-ms-expand {
93+
background-color: transparent;
94+
border: 0;
95+
}
96+
97+
/**
98+
* Fixes a bug in Safari Mobile 7.0+ where click events aren't fired on elements
99+
* that aren't typißcally interactive. See:
100+
* https://developer.mozilla.org/en-US/docs/Web/Events/click#Safari_Mobile.
101+
*/
102+
103+
[role='button'] {
104+
cursor: pointer;
105+
}

src/image-and-multimedia.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* Make all images responsive.
3+
*
4+
* 1. Override the height to 'auto', otherwise images will be stretched when
5+
* setting a width and height attribute on the `<img>` element.
6+
* 2. Set a maximum relative to the parent.
7+
*/
8+
9+
img {
10+
height: auto; /* 1 */
11+
max-width: 100%; /* 2 */
12+
}

0 commit comments

Comments
 (0)