diff options
Diffstat (limited to 'site/content/docs/5.0/getting-started')
| -rw-r--r-- | site/content/docs/5.0/getting-started/accessibility.md | 11 | ||||
| -rw-r--r-- | site/content/docs/5.0/getting-started/build-tools.md | 10 | ||||
| -rw-r--r-- | site/content/docs/5.0/getting-started/download.md | 10 | ||||
| -rw-r--r-- | site/content/docs/5.0/getting-started/introduction.md | 9 | ||||
| -rw-r--r-- | site/content/docs/5.0/getting-started/javascript.md | 9 | ||||
| -rw-r--r-- | site/content/docs/5.0/getting-started/parcel.md | 99 | ||||
| -rw-r--r-- | site/content/docs/5.0/getting-started/rtl.md | 44 | ||||
| -rw-r--r-- | site/content/docs/5.0/getting-started/webpack.md | 2 |
8 files changed, 177 insertions, 17 deletions
diff --git a/site/content/docs/5.0/getting-started/accessibility.md b/site/content/docs/5.0/getting-started/accessibility.md index c55df5026..e9f1cb316 100644 --- a/site/content/docs/5.0/getting-started/accessibility.md +++ b/site/content/docs/5.0/getting-started/accessibility.md @@ -10,7 +10,7 @@ Bootstrap provides an easy-to-use framework of ready-made styles, layout tools, ## Overview and limitations -The overall accessibility of any project built with Bootstrap depends in large part on the author's markup, additional styling, and scripting they've included. However, provided that these have been implemented correctly, it should be perfectly possible to create websites and applications with Bootstrap that fulfill [<abbr title="Web Content Accessibility Guidelines">WCAG</abbr> 2.1](https://www.w3.org/TR/WCAG21/) (A/AA/AAA), [Section 508](https://www.section508.gov/), and similar accessibility standards and requirements. +The overall accessibility of any project built with Bootstrap depends in large part on the author's markup, additional styling, and scripting they've included. However, provided that these have been implemented correctly, it should be perfectly possible to create websites and applications with Bootstrap that fulfill [<abbr title="Web Content Accessibility Guidelines">WCAG</abbr> 2.1](https://www.w3.org/TR/WCAG/) (A/AA/AAA), [Section 508](https://www.section508.gov/), and similar accessibility standards and requirements. ### Structural markup @@ -24,7 +24,7 @@ Because Bootstrap's components are purposely designed to be fairly generic, auth ### Color contrast -Some combinations of colors that currently make up Bootstrap's default palette—used throughout the framework for things such as button variations, alert variations, form validation indicators—may lead to *insufficient* color contrast (below the recommended [WCAG 2.1 text color contrast ratio of 4.5:1](https://www.w3.org/TR/WCAG21/#contrast-minimum) and the [WCAG 2.1 non-text color contrast ratio of 3:1](https://www.w3.org/TR/WCAG21/#non-text-contrast)), particularly when used against a light background. Authors are encouraged to test their specific uses of color and, where necessary, manually modify/extend these default colors to ensure adequate color contrast ratios. +Some combinations of colors that currently make up Bootstrap's default palette—used throughout the framework for things such as button variations, alert variations, form validation indicators—may lead to *insufficient* color contrast (below the recommended [WCAG 2.1 text color contrast ratio of 4.5:1](https://www.w3.org/TR/WCAG/#contrast-minimum) and the [WCAG 2.1 non-text color contrast ratio of 3:1](https://www.w3.org/TR/WCAG/#non-text-contrast)), particularly when used against a light background. Authors are encouraged to test their specific uses of color and, where necessary, manually modify/extend these default colors to ensure adequate color contrast ratios. ### Visually hidden content @@ -45,17 +45,18 @@ For visually hidden interactive controls, such as traditional "skip" links, use ### Reduced motion -Bootstrap includes support for the [`prefers-reduced-motion` media feature](https://drafts.csswg.org/mediaqueries-5/#prefers-reduced-motion). In browsers/environments that allow the user to specify their preference for reduced motion, most CSS transition effects in Bootstrap (for instance, when a modal dialog is opened or closed, or the sliding animation in carousels) will be disabled, and meaningful animations (such as spinners) will be slowed down. +Bootstrap includes support for the [`prefers-reduced-motion` media feature](https://www.w3.org/TR/mediaqueries-5/#prefers-reduced-motion). In browsers/environments that allow the user to specify their preference for reduced motion, most CSS transition effects in Bootstrap (for instance, when a modal dialog is opened or closed, or the sliding animation in carousels) will be disabled, and meaningful animations (such as spinners) will be slowed down. On browsers that support `prefers-reduced-motion`, and where the user has *not* explicitly signaled that they'd prefer reduced motion (i.e. where `prefers-reduced-motion: no-preference`), Bootstrap enables smooth scrolling using the `scroll-behavior` property. ## Additional resources -- [Web Content Accessibility Guidelines (WCAG) 2.1](https://www.w3.org/TR/WCAG21/) +- [Web Content Accessibility Guidelines (WCAG) 2.1](https://www.w3.org/TR/WCAG/) - [The A11Y Project](https://www.a11yproject.com/) - [MDN accessibility documentation](https://developer.mozilla.org/en-US/docs/Web/Accessibility) - [Tenon.io Accessibility Checker](https://tenon.io/) -- [Color Contrast Analyser (CCA)](https://developer.paciellogroup.com/resources/contrastanalyser/) +- [Color Contrast Analyser (CCA)](https://www.tpgi.com/color-contrast-checker/) - ["HTML Codesniffer" bookmarklet for identifying accessibility issues](https://github.com/squizlabs/HTML_CodeSniffer) - [Microsoft Accessibility Insights](https://accessibilityinsights.io/) - [Deque Axe testing tools](https://www.deque.com/axe/) +- [Introduction to Web Accessibility](https://www.w3.org/WAI/fundamentals/accessibility-intro/) diff --git a/site/content/docs/5.0/getting-started/build-tools.md b/site/content/docs/5.0/getting-started/build-tools.md index 46ad928d4..d0286375e 100644 --- a/site/content/docs/5.0/getting-started/build-tools.md +++ b/site/content/docs/5.0/getting-started/build-tools.md @@ -65,6 +65,16 @@ Our [package.json]({{< param repo >}}/blob/v{{< param current_version >}}/packag </tbody> </table> +{{< callout info >}} +{{< partial "callout-info-npm-starter.md" >}} +{{< /callout >}} + +## Sass + +Bootstrap uses [Dart Sass](https://sass-lang.com/dart-sass) for compiling our Sass source files into CSS files (included in our build process), and we recommend you do the same if you're compiling Sass using your own asset pipeline. We previously used Node Sass for Bootstrap v4, but LibSass and packages built on top of it, including Node Sass, are now [deprecated](https://sass-lang.com/blog/libsass-is-deprecated). + +Dart Sass uses a rounding precision of 10 and for efficiency reasons does not allow adjustment of this value. We don't lower this precision during further processing of our generated CSS, such as during minification, but if you chose to do so we recommend maintaining a precision of at least 6 to prevent issues with browser rounding. + ## Autoprefixer Bootstrap uses [Autoprefixer][autoprefixer] (included in our build process) to automatically add vendor prefixes to some CSS properties at build time. Doing so saves us time and code by allowing us to write key parts of our CSS a single time while eliminating the need for vendor mixins like those found in v3. diff --git a/site/content/docs/5.0/getting-started/download.md b/site/content/docs/5.0/getting-started/download.md index e053eac39..48578572b 100644 --- a/site/content/docs/5.0/getting-started/download.md +++ b/site/content/docs/5.0/getting-started/download.md @@ -21,10 +21,10 @@ This doesn't include documentation, source files, or any optional JavaScript dep Compile Bootstrap with your own asset pipeline by downloading our source Sass, JavaScript, and documentation files. This option requires some additional tooling: -- Sass compiler (Libsass or Ruby Sass is supported) for compiling your CSS. +- [Sass compiler]({{< docsref "/getting-started/build-tools#sass" >}}) for compiling Sass source files into CSS files - [Autoprefixer](https://github.com/postcss/autoprefixer) for CSS vendor prefixing -Should you require [build tools]({{< docsref "/getting-started/build-tools#tooling-setup" >}}), they are included for developing Bootstrap and its docs, but they're likely unsuitable for your own purposes. +Should you require our full set of [build tools]({{< docsref "/getting-started/build-tools#tooling-setup" >}}), they are included for developing Bootstrap and its docs, but they're likely unsuitable for your own purposes. <a href="{{< param "download.source" >}}" class="btn btn-bd-primary" onclick="ga('send', 'event', 'Getting started', 'Download', 'Download source');">Download source</a> @@ -52,7 +52,7 @@ If you're using our compiled JavaScript and prefer to include Popper separately, ## Package managers -Pull in Bootstrap's **source files** into nearly any project with some of the most popular package managers. No matter the package manager, Bootstrap will **require a Sass compiler and [Autoprefixer](https://github.com/postcss/autoprefixer)** for a setup that matches our official compiled versions. +Pull in Bootstrap's **source files** into nearly any project with some of the most popular package managers. No matter the package manager, Bootstrap will **require a [Sass compiler]({{< docsref "/getting-started/build-tools#sass" >}}) and [Autoprefixer](https://github.com/postcss/autoprefixer)** for a setup that matches our official compiled versions. ### npm @@ -70,6 +70,10 @@ Bootstrap's `package.json` contains some additional metadata under the following - `sass` - path to Bootstrap's main [Sass](https://sass-lang.com/) source file - `style` - path to Bootstrap's non-minified CSS that's been precompiled using the default settings (no customization) +{{< callout info >}} +{{< partial "callout-info-npm-starter.md" >}} +{{< /callout >}} + ### yarn Install Bootstrap in your Node.js powered apps with [the yarn package](https://yarnpkg.com/en/package/bootstrap): diff --git a/site/content/docs/5.0/getting-started/introduction.md b/site/content/docs/5.0/getting-started/introduction.md index 9cd0890c3..9cb85e6c5 100644 --- a/site/content/docs/5.0/getting-started/introduction.md +++ b/site/content/docs/5.0/getting-started/introduction.md @@ -24,7 +24,7 @@ Copy-paste the stylesheet `<link>` into your `<head>` before all other styleshee ### JS -Many of our components require the use of JavaScript to function. Specifically, they require our own JavaScript plugins and [Popper](https://popper.js.org/). Place **one of following `<script>`s** near the end of your pages, right before the closing `</body>` tag, to enable them. +Many of our components require the use of JavaScript to function. Specifically, they require our own JavaScript plugins and [Popper](https://popper.js.org/). Place **one of the following `<script>`s** near the end of your pages, right before the closing `</body>` tag, to enable them. #### Bundle @@ -101,7 +101,7 @@ Be sure to have your pages set up with the latest design and development standar </html> ``` -That's all you need for overall page requirements. Visit the [Layout docs]({{< docsref "/layout/grid" >}}) or [our official examples]({{< docsref "/examples" >}}) to start laying out your site's content and components. +For next steps, visit the [Layout docs]({{< docsref "/layout/grid" >}}) or [our official examples]({{< docsref "/examples" >}}) to start laying out your site's content and components. ## Important globals @@ -130,7 +130,7 @@ You can see an example of this in action in the [starter template](#starter-temp ### Box-sizing -For more straightforward sizing in CSS, we switch the global `box-sizing` value from `content-box` to `border-box`. This ensures `padding` does not affect the final computed width of an element, but it can cause problems with some third party software like Google Maps and Google Custom Search Engine. +For more straightforward sizing in CSS, we switch the global `box-sizing` value from `content-box` to `border-box`. This ensures `padding` does not affect the final computed width of an element, but it can cause problems with some third-party software like Google Maps and Google Custom Search Engine. On the rare occasion you need to override it, use something like the following: @@ -152,11 +152,10 @@ For improved cross-browser rendering, we use [Reboot]({{< docsref "/content/rebo Stay up to date on the development of Bootstrap and reach out to the community with these helpful resources. -- Follow [@getbootstrap on Twitter](https://twitter.com/{{< param twitter >}}). - Read and subscribe to [The Official Bootstrap Blog]({{< param blog >}}). - Join [the official Slack room]({{< param slack >}}). - Chat with fellow Bootstrappers in IRC. On the `irc.freenode.net` server, in the `##bootstrap` channel. - Implementation help may be found at Stack Overflow (tagged [`bootstrap-5`](https://stackoverflow.com/questions/tagged/bootstrap-5)). -- Developers should use the keyword `bootstrap` on packages which modify or add to the functionality of Bootstrap when distributing through [npm](https://www.npmjs.com/search?q=keywords:bootstrap) or similar delivery mechanisms for maximum discoverability. +- Developers should use the keyword `bootstrap` on packages that modify or add to the functionality of Bootstrap when distributing through [npm](https://www.npmjs.com/search?q=keywords:bootstrap) or similar delivery mechanisms for maximum discoverability. You can also follow [@getbootstrap on Twitter](https://twitter.com/{{< param twitter >}}) for the latest gossip and awesome music videos. diff --git a/site/content/docs/5.0/getting-started/javascript.md b/site/content/docs/5.0/getting-started/javascript.md index 53845fdfc..f57a3aedf 100644 --- a/site/content/docs/5.0/getting-started/javascript.md +++ b/site/content/docs/5.0/getting-started/javascript.md @@ -93,6 +93,15 @@ var modal = new bootstrap.Modal(myModalEl, { keyboard: false }) // initialized w If you'd like to get a particular plugin instance, each plugin exposes a `getInstance` method. In order to retrieve it directly from an element, do this: `bootstrap.Popover.getInstance(myPopoverEl)`. +### CSS selectors in constructors + +You can also use a CSS selector as the first argument instead of a DOM element to initialize the plugin. Currently the element for the plugin is found by the `querySelector` method since our plugins support a single element only. + +```js +var modal = new bootstrap.Modal('#myModal') +var dropdown = new bootstrap.Dropdown('[data-bs-toggle="dropdown"]') +``` + ### Asynchronous functions and transitions All programmatic API methods are **asynchronous** and return to the caller once the transition is started but **before it ends**. diff --git a/site/content/docs/5.0/getting-started/parcel.md b/site/content/docs/5.0/getting-started/parcel.md new file mode 100644 index 000000000..23aab0054 --- /dev/null +++ b/site/content/docs/5.0/getting-started/parcel.md @@ -0,0 +1,99 @@ +--- +layout: docs +title: Parcel +description: Learn how to include Bootstrap in your project using Parcel. +group: getting-started +toc: true +--- + +## Install Parcel + +Install [Parcel Bundler](https://en.parceljs.org/getting_started.html). + +## Install Bootstrap + +[Install bootstrap]({{< docsref "/getting-started/download#npm" >}}) as a Node.js module using npm. + +Bootstrap depends on [Popper](https://popper.js.org/), which is specified in the `peerDependencies` property. This means that you will have to make sure to add both of them to your `package.json` using `npm install @popperjs/core`. + +When all will be completed, your project will be structured like this: + +```text +project-name/ +├── build/ +├── node_modules/ +│ └── bootstrap/ +│ └── popper.js/ +├── scss/ +│ └── custom.scss +├── src/ +│ └── index.html +│ └── index.js +└── package.json +``` + +## Importing JavaScript + +Import [Bootstrap's JavaScript]({{< docsref "/getting-started/javascript" >}}) in your app's entry point (usually `src/index.js`). You can import all our plugins in one file or separately if you require only a subset of them. + +```js +// Import all plugins +import * as bootstrap from 'bootstrap'; + +// Or import only needed plugins +import { Tooltip as Tooltip, Toast as Toast, Popover as Popover } from 'bootstrap'; + +// Or import just one +import Alert as Alert from '../node_modules/bootstrap/js/dist/alert'; +``` + +## Importing CSS + +To utilize the full potential of Bootstrap and customize it to your needs, use the source files as a part of your project's bundling process. + +Create your own `scss/custom.scss` to [import Bootstrap's Sass files]({{< docsref "/customize/sass#importing" >}}) and then override the [built-in custom variables]({{< docsref "/customize/sass#variable-defaults" >}}). + +## Build app + +Include `src/index.js` before the closing `</body>` tag. + +```html +<!doctype html> +<html lang="en"> + <head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + </head> + <body> + <script src="./index.js"></script> + </body> +</html> +``` + +### Edit `package.json` + +Add `dev` and `build` scripts in your `package.json` file. + +```json +"scripts": { + "dev": "parcel ./src/index.html", + "prebuild": "npx rimraf build", + "build": "parcel build --public-url ./ ./src/index.html --experimental-scope-hoisting --out-dir build" +} +``` + +### Run dev script + +Your app will be accessible at `http://127.0.0.1:1234`. + +```sh +npm run dev +``` + +### Build app files + +Built files are in the `build/` folder. + +```sh +npm run build +``` diff --git a/site/content/docs/5.0/getting-started/rtl.md b/site/content/docs/5.0/getting-started/rtl.md index 62287a341..3e1f7a207 100644 --- a/site/content/docs/5.0/getting-started/rtl.md +++ b/site/content/docs/5.0/getting-started/rtl.md @@ -53,10 +53,10 @@ You can see the above requirements reflected in this modified RTL starter templa <!-- Optional JavaScript; choose one of the two! --> - <!-- Option 1: Bootstrap Bundle with Popper.js --> + <!-- Option 1: Bootstrap Bundle with Popper --> <script src="{{< param "cdn.js_bundle" >}}" integrity="{{< param "cdn.js_bundle_hash" >}}" crossorigin="anonymous"></script> - <!-- Option 2: Separate Popper.js and Bootstrap JS --> + <!-- Option 2: Separate Popper and Bootstrap JS --> <!-- <script src="{{< param "cdn.popper" >}}" integrity="{{< param "cdn.popper_hash" >}}" crossorigin="anonymous"></script> <script src="{{< param "cdn.js" >}}" integrity="{{< param "cdn.js_hash" >}}" crossorigin="anonymous"></script> @@ -93,7 +93,7 @@ Using [RTLCSS value directives](https://rtlcss.com/learn/usage-guide/value-direc $font-weight-bold: 700 #{/* rtl:600 */} !default; ``` -Which would ouput to the following for our default CSS and RTL CSS: +Which would output to the following for our default CSS and RTL CSS: ```css /* bootstrap.css */ @@ -116,6 +116,8 @@ For example, to switch from `Helvetica Neue Webfont` for LTR to `Helvetica Neue ```scss $font-family-sans-serif: Helvetica Neue #{"/* rtl:insert:Arabic */"}, + // Cross-platform generic font family (default user interface font) + system-ui, // Safari for macOS and iOS (San Francisco) -apple-system, // Chrome < 56 for macOS (San Francisco) @@ -134,6 +136,42 @@ $font-family-sans-serif: "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji" !default; ``` +### LTR and RTL at the same time + +Need both LTR and RTL on the same page? Thanks to [RTLCSS String Maps](https://rtlcss.com/learn/usage-guide/string-map/), this is pretty straightforward. Wrap your `@import`s with a class, and set a custom rename rule for RTLCSS: + +```scss +/* rtl:begin:options: { + "autoRename": true, + "stringMap":[ + "name": "ltr-rtl", + "priority": 100, + "search": ["ltr"], + "replace": ["rtl"], + "options": { + "scope": "*", + "ignoreCase": false + } + ] +} */ +.ltr { + @import "../node_modules/bootstrap/scss/bootstrap"; +} +/*rtl:end:options*/ +``` + +After running Sass then RTLCSS, each selector in your CSS files will be prepended by `.ltr`, and `.rtl` for RTL files. Now you're able to use both files on the same page, and simply use `.ltr` or `.rtl` on your components wrappers to use one or the other direction. + +{{< callout warning >}} +#### Edge cases and known limitations + +While this approach is understandable, please pay attention to the following: + +1. When switching `.ltr` and `.rtl`, make sure you add `dir` and `lang` attributes accordingly. +2. Loading both files can be a real performance bottleneck: consider some [optimization]({{< docsref "/customize/optimize" >}}), and maybe try to [load one of those files asynchronously](https://www.filamentgroup.com/lab/load-css-simpler/). +3. Nesting styles this way will prevent our `form-validation-state()` mixin from working as intended, thus require you tweak it a bit by yourself. [See #31223](https://github.com/twbs/bootstrap/issues/31223). +{{< /callout >}} + ## The breadcrumb case The [breadcrumb separator]({{< docsref "/components/breadcrumb" >}}/#changing-the-separator) is the only case requiring its own brand new variable— namely `$breadcrumb-divider-flipped` —defaulting to `$breadcrumb-divider`. diff --git a/site/content/docs/5.0/getting-started/webpack.md b/site/content/docs/5.0/getting-started/webpack.md index 4b9c525dd..6998e1e99 100644 --- a/site/content/docs/5.0/getting-started/webpack.md +++ b/site/content/docs/5.0/getting-started/webpack.md @@ -27,7 +27,7 @@ import Alert from 'bootstrap/js/dist/alert'; ``` Bootstrap depends on [Popper](https://popper.js.org/), which is specified in the `peerDependencies` property. -This means that you will have to make sure to add it to your `package.json` using `npm install popper.js`. +This means that you will have to make sure to add it to your `package.json` using `npm install @popperjs/core`. ## Importing Styles |
