|
1 | | -# backpack.css 🎒 |
| 1 | +# backpack.css 🎒 <!-- omit in toc --> |
2 | 2 |
|
3 | | -A lightweight and somewhat opinionated CSS foundation that is best suited to applications. |
| 3 | +A lightweight and somewhat opinionated CSS foundation that is best suited to |
| 4 | +applications. |
4 | 5 |
|
5 | | -⚠️ Under development, version 1.0.0 coming soon. |
| 6 | +## Table of contents <!-- omit in toc --> |
| 7 | + |
| 8 | +- [Installation](#installation) |
| 9 | +- [How to use](#how-to-use) |
| 10 | + - [Importing with a bundler](#importing-with-a-bundler) |
| 11 | + - [Importing without a bundler](#importing-without-a-bundler) |
| 12 | + - [Overriding](#overriding) |
| 13 | +- [Motivation](#motivation) |
| 14 | +- [What it does](#what-it-does) |
| 15 | +- [Evolution](#evolution) |
| 16 | +- [Browser support](#browser-support) |
| 17 | + |
| 18 | +## Installation |
| 19 | + |
| 20 | +Run the following command using [npm](https://www.npmjs.com/): |
| 21 | + |
| 22 | +```bash |
| 23 | +npm install backpack.css --save-dev |
| 24 | +``` |
| 25 | + |
| 26 | +If you prefer [Yarn](https://yarnpkg.com/en/), use this command instead: |
| 27 | + |
| 28 | +```bash |
| 29 | +yarn add backpack.css --dev |
| 30 | +``` |
| 31 | + |
| 32 | +Or you can link to a minified version hosted on [CDNJS](https://cdnjs.com/about) |
| 33 | +but make sure it comes before any of your project's CSS: |
| 34 | + |
| 35 | +```html |
| 36 | +<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/backpack.css/[version]/backpack.min.css" /> |
| 37 | +<link rel="stylesheet" href="[path-to-your-project-css]" /> |
| 38 | +``` |
| 39 | + |
| 40 | +## How to use |
| 41 | + |
| 42 | +Typically you'll be wanting to import all of backpack.css styles into your |
| 43 | +project but you do have the choice to be selective. |
| 44 | + |
| 45 | +The one strict rule backpack.css does have is that it must come before your |
| 46 | +project's CSS to ensure correct ordering of your styles and if you need to |
| 47 | +override any of backpack.css styles. |
| 48 | + |
| 49 | +### Importing with a bundler |
| 50 | + |
| 51 | +If you're using a bundler such as [webpack](https://webpack.js.org/) and wanting |
| 52 | +to import all of backpack.css then your app's entry point should look like this: |
| 53 | + |
| 54 | +```js |
| 55 | +import 'backpack.css'; |
| 56 | +import '[path-to-your-project-css]'; |
| 57 | +``` |
| 58 | + |
| 59 | +If you want to be selective on what to import then simply `import` the |
| 60 | +backpack.css files you need, for example: |
| 61 | + |
| 62 | +```js |
| 63 | +import 'backpack.css/resets.css'; |
| 64 | +import 'backpack.css/content-sectioning.css'; |
| 65 | +import 'backpack.css/forms.css'; |
| 66 | +import '[path-to-your-project-css]'; |
| 67 | +``` |
| 68 | + |
| 69 | +The order at which you import each module is important, to see this order and |
| 70 | +what `.css` files are available refer to backpack.css `index.css`. |
| 71 | + |
| 72 | +### Importing without a bundler |
| 73 | + |
| 74 | +Simply include a `<link>` element that references the |
| 75 | +[CDNJS](https://cdnjs.com/about) version of backpack.css, for example: |
| 76 | + |
| 77 | +```html |
| 78 | +<html> |
| 79 | + <head> |
| 80 | + […] |
| 81 | + <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/backpack.css/[version]/backpack.min.css" /> |
| 82 | + <link rel="stylesheet" href="[path-to-your-project-css]" /> |
| 83 | + </head> |
| 84 | + <body> |
| 85 | + […] |
| 86 | + </body> |
| 87 | +<html> |
| 88 | +``` |
| 89 | + |
| 90 | +For better performance and versioning it's recommended to use the CDNJS version, |
| 91 | +however, you don't have to, you can |
| 92 | +[download](https://github.com/chris-pearce/backpack.css/archive/master.zip) |
| 93 | +backpack.css from Github. |
| 94 | + |
| 95 | +### Overriding |
| 96 | + |
| 97 | +backpack.css is just CSS so you can easily override any of backpack.css styles just as |
| 98 | +you would override any CSS, as in, via the rules of the cascade and specificity. |
| 99 | + |
| 100 | +For example, if you didn't want to use `system-ui` as the global `font-family` |
| 101 | +set in `main-root.css` then simply redeclare it in your project's CSS like so: |
| 102 | + |
| 103 | +```css |
| 104 | +html { |
| 105 | + font-family: serif; |
| 106 | +} |
| 107 | +``` |
| 108 | + |
| 109 | +As already mentioned above if you aren't needing entire modules |
| 110 | + |
| 111 | +## Motivation |
| 112 | + |
| 113 | +Nowadays I'm building [React](https://reactjs.org/) applications that have |
| 114 | +highly componentised User Interfaces (UI) making use of native CSS layout |
| 115 | +mechanisms such as |
| 116 | +[Flexbox](https://css-tricks.com/snippets/css/a-guide-to-flexbox/) and |
| 117 | +[Grid](https://css-tricks.com/snippets/css/complete-guide-grid/). I'm no longer |
| 118 | +finding the need for heavy handed CSS frameworks that handle most of my UI |
| 119 | +concerns, especially layout. Instead I build components with a smidgen of global |
| 120 | +styles. |
| 121 | + |
| 122 | +What I do need, however, are a bunch of smart and sensible foundational styles |
| 123 | +suited for applications that I would typically forget project to project—think |
| 124 | +[Normalize.css](http://necolas.github.io/normalize.css/) and then some. |
| 125 | +Something that is lightweight, super easy to intergrate, and can easily be |
| 126 | +overriden or allow for modular use, thus giving birth to backpack.css 🙂. |
| 127 | + |
| 128 | +## What it does |
| 129 | + |
| 130 | +_Coming soon…_ |
| 131 | + |
| 132 | +## Evolution |
| 133 | + |
| 134 | +This is the third CSS framework/library I've created. Looking at each one really |
| 135 | +lets you see how UI development has evolved over the years with each iteration |
| 136 | +getting smaller and smaller. |
| 137 | + |
| 138 | +1. [Scally](https://github.com/chris-pearce/scally) _circa 2014_ |
| 139 | +2. [Shell](https://github.com/campaignmonitor/shell) _circa 2016_ |
| 140 | +3. [backpack.css](https://github.com/chris-pearce/backpack.css) _circa 2018_ |
| 141 | + |
| 142 | +## Browser support |
| 143 | + |
| 144 | +_Coming soon…_ |
| 145 | + |
| 146 | +<!-- ## What it does |
| 147 | +
|
| 148 | +- Applies sensible OpenType features to select elements. For example, table |
| 149 | + cells (`<td>`) have enabled: |
| 150 | + - _lining numerals_ |
| 151 | + - _tabular numerals_ |
| 152 | + - _slashed zero_ |
| 153 | +- Resets all margins |
| 154 | +- each `.css` file is completely standalone --> |
| 155 | + |
| 156 | +<!-- ## What it doesn't do |
| 157 | +
|
| 158 | +where's my utils, just create a component! |
| 159 | +
|
| 160 | +## TODO |
| 161 | +
|
| 162 | +* Explain headings |
| 163 | +* Sensible defaults, fixing bugs, improving a11y/UX, helping responsive, |
| 164 | +* https://hackernoon.com/the-coolest-react-ui-frameworks-for-your-new-react-app-ad699fffd651 --> |
0 commit comments