- commit
- 323a87f32b4eddb1c73700a266a6943beb9a19e9
- parent
- 8f35cab3b7f7cba0cd3af72e3075248637c50a72
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2017-05-09 21:04
rewrite readme
Diffstat
| M | README.md | 154 | +++++++++++-------------------------------------------------- |
1 files changed, 27 insertions, 127 deletions
diff --git a/README.md b/README.md
@@ -2,6 +2,10 @@ mfbs (motherfuckingbootstap) is a CSS microframework inspired by [twitter 2 2 bootstrap](https://getbootstrap.com/) and 3 3 <http://bettermotherfuckingwebsite.com/>. 4 4 -1 5 I found that I started every new project with mostly the same CSS code. So -1 6 instead of duplicating that code again and again, I distilled the base styles -1 7 from several projects into this little library. -1 8 5 9 It is written in [Sass](http://sass-lang.com/) and consists of variable 6 10 definitions (`variables.scss`), some basic styling (`base.scss`) and some 7 11 optional components. @@ -10,14 +14,7 @@ See how it looks 10 14 [here](https://xi.github.io/mfbs/examples/motherfuckingwebsite.html) and 11 15 [here](https://xi.github.io/mfbs/examples/styleguide.html). 12 1613 -1 # how to use it14 -115 -1 First, install via bower or npm (eyeglass):16 -117 -1 bower install xi/mfbs18 -1 npm install mfbs19 -120 -1 Then, create a master stylesheet like this:-1 17 ## how to use it 21 18 22 19 // First, define your own variables 23 20 @import "variables"; @@ -26,7 +23,7 @@ Then, create a master stylesheet like this: 26 23 @import "mfbs/variables"; 27 24 @import "mfbs/base"; 28 2529 -1 // Optionally import some components-1 26 // Optionally import some opinionated styling 30 27 @import "mfbs/form"; 31 28 32 29 // Import your own components @@ -34,121 +31,24 @@ Then, create a master stylesheet like this: 34 31 @import "components/navigation"; 35 32 @import "components/article"; 36 3337 -1 # the fuck?38 -139 -1 I tend to duplicate a lot of basic styling between projects. So naturally I was40 -1 looking for ways to reduce that duplication. Twitter bootstrap is nice, but it41 -1 does so much more than what I needed. So instead I rolled my own.42 -143 -1 Here's the philosophy:44 -145 -1 - A site using no styling except for mfbs should have decent usability.46 -1 - mfbs should be as minimal as possible47 -1 - no workarounds for browser bugs48 -1 - opinionated styling should go into optional components49 -1 - leverage default styles50 -1 - apart from providing basic styling, mfbs should define and promote a51 -1 workflow for writing CSS52 -1 - based on [OOCSS](http://oocss.org/) and [Sass](http://sass-lang.com/)53 -1 - naming conventions54 -1 - use variables for all colors55 -1 - prefer relative units56 -1 - accessibility57 -158 -1 # A brief introduction to web design (slightly opinionated)59 -160 -1 ## WYSIWYM (What you see is what you mean)61 -162 -1 Web design is fundamentally different from many other forms of design,63 -1 especially print, because you can not see the final product. Of course, you can64 -1 look at a webpage in your browser, but you will never be able to see or even65 -1 imagine that page on all possible devices, with all possible browsers and66 -1 browser extensions, let alone user generated content. That is why instead of67 -1 coding what you want to see, you should write what you mean.68 -169 -1 Example: You want to center some text on the screen, so increase the70 -1 `margin-left` to something like 1100px and it looks fine, right? Maybe on your71 -1 screen, but definitely not on a mobile device. Instead, you should use72 -1 `text-align: center`. With this information, the browsers can understand what73 -1 you want and do their best to produce a usable result.74 -175 -1 ## Maintenance76 -177 -1 A website is typically never finished. Make sure that you will still be able to78 -1 understand your code one year from now!79 -180 -1 Example: Styling elements based on context (using descendant selectors) may81 -1 seem like a good idea, but it soon gets extremely complicated to understand82 -1 which rules apply to which element with which priority.83 -184 -1 ## Progressive enhancement85 -186 -1 Not all clients provide the same features. Think about small screens, outdated87 -1 browsers, blocked JavaScript, or assistive technology. You should never rely on88 -1 these advanced features. Instead, use them to optionally enhance user89 -1 experience if additional features are available.90 -191 -1 Example: Build your website for small screens by default. If more screenspace92 -1 is available (check via [media93 -1 queries](https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries))94 -1 you can switch to an optimized layout (this approach is called "mobile first").95 -196 -1 ## Separate style, functionality, and content97 -198 -1 The web is build with three distinct languages: HTML for content, JavaScript99 -1 for functionality and CSS for styling. Make sure that you have a clear100 -1 separation between these areas!101 -1102 -1 Example: Do not use element selectors in CSS. They break easily when you change103 -1 your HTML. Instead, use semantic class names.104 -1105 -1 ## Conventions106 -1107 -1 People spend much more time on other peoples websites, so do not try to get108 -1 fancy. Just do what everyone is doing, that's just fine.109 -1110 -1 Example: Links are much more likely to be fund if they are blue and underlined.111 -1112 -1 ## Use appropriate units113 -1114 -1 For some reason, people seem to be afraid of using different units in their115 -1 stylesheets. There seems to be a `px` camp, a `em` camp and since recently also116 -1 a `rem` camp. But the truth is: Each of these units is different and has their117 -1 specific use. Learn the meaning of each of them and when to use it!118 -1119 -1 ## Objects, states, and modifiers120 -1121 -1 You can not possibly think about the complete interface at once. Instead,122 -1 divide it into meaningful parts. Here is how I do it:123 -1124 -1 Object125 -1 : An object is a part of the UI that could stand on its own or be repeated in126 -1 different places. It can be anything from a link to a login form or a127 -1 layout structure. Objects are references by their classname, which should128 -1 be dashed-lowercase (e.g. `.login-form`).129 -1130 -1 Note: Splitting your UI into objects is not as easy as you might think.131 -1 Take special care to get this right! For example, you might want to split132 -1 layout and styling into separate objects.133 -1134 -1 Modifier135 -1 : Sometimes you might want to have a slightly modified variant of an existing136 -1 object. In that case, create a modifier class that is prefixed with `m-`137 -1 (e.g. `.button.m-call-to-action`).138 -1139 -1 State140 -1 : If the state of an object can be changed on runtime, use a state class that141 -1 is prefixed `is-` or `has-`. Alternatively, utilize the existing pseudo142 -1 classes (e.g. `a.is-active`, `a:disabled`).143 -1144 -1 ## Use variables145 -1146 -1 If you use the same values in several places, make that explicit by defining it147 -1 as a variable with a semantic name. Colors are an obvious example, but this148 -1 also makes sense for some length values.149 -1150 -1 ## Living styleguide151 -1152 -1 To keep an overview of everything you have done, you should create a page with153 -1 examples and descriptions for all your objects, modifiers, states and154 -1 variables.-1 34 ## features -1 35 -1 36 - mfbs on its own is completely sufficient for simple text-only websites. -1 37 - It can easily be customized with variables. -1 38 - The default colors were carefully picked to look nice and satisfy minimum -1 39 contrast requirements. -1 40 - Opinionated styling for buttons, layout, and some more things is available -1 41 in optional modules. -1 42 - Base styles have low specificity, so they can easily be extended with -1 43 custom components. -1 44 - The small set of variables is very focused and scales well for projects of -1 45 any size. -1 46 -1 47 ## when to use -1 48 -1 49 - Use the default for simple general-purpose styling -1 50 - For small projects, overwrite some variables and define some custom -1 51 components (e.g. header) -1 52 - For large projects, you probably do not want to include the optional, -1 53 opinionated modules. But the base styles and variables are still a solid -1 54 base to build on.