|
1 | | -# backpack.css 🎒 |
| 1 | +# backpack.css 🎒 <!-- omit in toc --> |
2 | 2 |
|
3 | 3 | A lightweight and somewhat opinionated CSS foundation that is best suited to applications. |
4 | 4 |
|
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). |
0 commit comments