From 298de4df0878a9c0f2c40155d7e22c27713c9d48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20D=C3=A9ramond?= Date: Tue, 30 Jul 2024 12:33:32 +0200 Subject: [PATCH] docs(extend): add 'Approach' page (#2650) --- site/content/docs/0.0/extend/approach.md | 84 +++++++++++++++++++++++- site/data/sidebar.yml | 1 - 2 files changed, 83 insertions(+), 2 deletions(-) diff --git a/site/content/docs/0.0/extend/approach.md b/site/content/docs/0.0/extend/approach.md index 0536bbd35f..2810cd081c 100644 --- a/site/content/docs/0.0/extend/approach.md +++ b/site/content/docs/0.0/extend/approach.md @@ -10,4 +10,86 @@ aliases: - "/docs/extend/approach/" --- -{{< callout-soon "page" >}} +While the getting started pages provide an introductory tour of the project and what it offers, this document focuses on _why_ we do the things we do in OUDS Web. It explains our philosophy to building on the web so that others can learn from us, contribute with us, and help us improve. + +See something that doesn't sound right, or perhaps could be done better? [Open an issue]({{< param repo >}}/issues/new/choose)—we'd love to discuss it with you. + +## Summary + +We'll dive into each of these more throughout, but at a high level, here's what guides our approach. + +- Components should be responsive and mobile-first +- Components should be built with a base class and extended via modifier classes +- Component states should obey a common z-index scale +- Whenever possible, prefer an HTML and CSS implementation over JavaScript +- Whenever possible, use utilities over custom styles +- Whenever possible, avoid enforcing strict HTML requirements (children selectors) + +## Responsive + +OUDS Web's responsive styles are built to be responsive, an approach that's often referred to as _mobile-first_. We use this term in our docs and largely agree with it, but at times it can be too broad. While not every component _must_ be entirely responsive in OUDS Web, this responsive approach is about reducing CSS overrides by pushing you to add styles as the viewport becomes larger. + + + +## Classes + +Aside from our Reboot, a cross-browser normalization stylesheet, all our styles aim to use classes as selectors. This means steering clear of type selectors (e.g., `input[type="text"]`) and extraneous parent classes (e.g., `.parent .child`) that make styles too specific to easily override. + +As such, components should be built with a base class that houses common, not-to-be overridden property-value pairs. + +Modifier classes should only be used when there are multiple properties or values to be changed across multiple variants. Modifiers are not always necessary, so be sure you're actually saving lines of code and preventing unnecessary overrides when creating them. Good examples of modifiers are our theme color classes and size variants. + + + +## HTML and CSS over JS + +Whenever possible, we prefer to write HTML and CSS over JavaScript. In general, HTML and CSS are more prolific and accessible to more people of all different experience levels. HTML and CSS are also faster in your browser than JavaScript, and your browser generally provides a great deal of functionality for you. + +This principle is our first-class JavaScript API using `data` attributes. You don't need to write nearly any JavaScript to use our JavaScript plugins; instead, write HTML. + +Lastly, our styles build on the fundamental behaviors of common web elements. Whenever possible, we prefer to use what the browser provides. + +The same goes for more complex components. While we _could_ write our own form validation plugin to add classes to a parent element based on an input's state, thereby allowing us to style the text say red, we prefer using the `:valid`/`:invalid` pseudo-elements every browser provides us. + + + +## Flexible HTML + +While not always possible, we strive to avoid being overly dogmatic in our HTML requirements for components. Thus, we focus on single classes in our CSS selectors and try to avoid immediate children selectors (`>`). This gives you more flexibility in your implementation and helps keep our CSS simpler and less specific. + +## Code conventions + +[Code Guide](https://codeguide.co/) (from Bootstrap co-creator, @mdo) documents how we write our HTML and CSS across OUDS Web. It specifies guidelines for general formatting, common sense defaults, property and attribute orders, and more. + +We use [Stylelint](https://stylelint.io/) to enforce these standards and more in our Sass/CSS. [Bootstrap custom Stylelint config](https://github.com/twbs/stylelint-config-twbs-bootstrap) is open source and available for others to use and extend. + +We use [vnu-jar](https://www.npmjs.com/package/vnu-jar) to enforce standard and semantic HTML, as well as detecting common errors. diff --git a/site/data/sidebar.yml b/site/data/sidebar.yml index 2ac4e672bb..54d128f135 100644 --- a/site/data/sidebar.yml +++ b/site/data/sidebar.yml @@ -259,7 +259,6 @@ icon_color: body-color pages: - title: Approach - draft: true - title: Icons draft: true