Skip to content

Commit

Permalink
feat(components): new Sticker component (#1023)
Browse files Browse the repository at this point in the history
  • Loading branch information
julien-deramond authored Mar 1, 2022
1 parent 226172f commit b466b27
Show file tree
Hide file tree
Showing 13 changed files with 402 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .bundlewatch.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
},
{
"path": "./dist/css/boosted.css",
"maxSize": "29.9 kB"
"maxSize": "30.0 kB"
},
{
"path": "./dist/css/boosted.min.css",
"maxSize": "27.7 kB"
"maxSize": "27.8 kB"
},
{
"path": "./dist/js/boosted.bundle.js",
Expand Down
1 change: 1 addition & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
"scrollbars",
"scrollspy",
"Segoe",
"semantize",
"srcset",
"stickied",
"Stylelint",
Expand Down
39 changes: 39 additions & 0 deletions scss/_sticker.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
.sticker {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: $sticker-size-md;
height: $sticker-size-md;
font-weight: $font-weight-bold;
text-align: center;
word-wrap: break-word;
background-color: $brand-orange;
border-radius: $sticker-size-lg; // stylelint-disable-line property-disallowed-list

> * {
max-width: $sticker-content-max-width-md;
}

// Large sticker

&.sticker-lg {
width: $sticker-size-lg;
height: $sticker-size-lg;

> * {
max-width: $sticker-content-max-width-lg;
}
}

// Small sticker

&.sticker-sm {
width: $sticker-size-sm;
height: $sticker-size-sm;

> * {
max-width: $sticker-content-max-width-sm;
}
}
}
12 changes: 12 additions & 0 deletions scss/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1879,6 +1879,18 @@ $step-item-arrow-width: 1rem !default;
$step-item-arrow-shape: polygon(0% 0%, subtract(100%, $border-width) 50%, 0% 100%) #{"/* rtl:"} polygon(100% 0%, $border-width 50%, 100% 100%) #{"*/"} !default; // Used in clip-path
// scss-docs-end stepped-process

//// Sticker
// scss-docs-start sticker
$sticker-size-sm: $spacer * 7 !default;
$sticker-size-md: $spacer * 9 !default;
$sticker-size-lg: $spacer * 14 !default;

// Considering @use "sass:math", math.sqrt(2) / 2 is approximated to 0.7071067812
$sticker-content-max-width-sm: $sticker-size-sm * .7071067812 !default;
$sticker-content-max-width-md: $sticker-size-md * .7071067812 !default;
$sticker-content-max-width-lg: $sticker-size-lg * .7071067812 !default;
// scss-docs-end sticker

//// Quantity selector
// scss-docs-start quantity-selector
$quantity-selector-width: 7.5rem !default;
Expand Down
3 changes: 2 additions & 1 deletion scss/boosted.scss
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@

// Boosted
@import "back-to-top";
@import "stepped-process";
@import "orange-navbar";
@import "stepped-process";
@import "sticker";

// Helpers
@import "helpers";
Expand Down
2 changes: 1 addition & 1 deletion site/content/docs/5.1/about/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Boosted ships with custom accessible components to suit specific needs:
- [Star rating]({{< docsref "/forms/checks-radios#star-rating" >}})
- [Quantity selector]({{< docsref "/forms/quantity-selector" >}})
- [Stepped process]({{< docsref "/components/stepped-process" >}})

- [Sticker]({{< docsref "/components/sticker" >}})

## Bootstrap Team

Expand Down
90 changes: 90 additions & 0 deletions site/content/docs/5.1/components/sticker.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
---
layout: docs
title: Sticker
description: Use Boosted's custom stickers to inform people about new offers.
group: components
toc: true
---

## Example

{{< example >}}
<div class="sticker">
<p class="mb-0">
<span class="display-3 mb-0 d-block">39.99 €</span>
<span>Per month</span>
</p>
</div>
{{< /example >}}

## How it works

A **sticker** is basically a rounded container. All its content is centered horizontally and vertically.

A max width is set for this content so that it fits easily within the circle.

We provide [a set of stickers examples]({{< docsref "/examples/stickers" >}}) representing several use cases.

{{< callout warning >}}
**Positioning**

This flexibility means that the stickers can vary from the design specifications regarding the vertical positioning of content.

For a better rendering you can use our margin utilities or even CSS.
{{< /callout >}}

{{< callout warning >}}
**Font sizes and responsiveness**

All the provided examples use our text utilities to facilitate the understanding and to match the examples from the Orange Design System in desktop mode.

**Please be aware that those examples are not meant to be responsive** because they will always depend on the context. Indeed the font size will be resized in small screens due to the text utilities. If you do not want this behavior, you could for example set fixed font sizes and add some responsive rules by using `scale()` CSS function.
{{< /callout >}}

## Sizes

Fancy larger or smaller stickers? Add `.sticker-lg` or `.sticker-sm` for additional sizes.

**Don't forget to adjust the size of the content.**

{{< example >}}
<div class="sticker sticker-lg">
<p class="mb-0">
<span class="display-1">New</span>
</p>
</div>
{{< /example >}}

{{< example >}}
<div class="sticker sticker-sm">
<p class="mb-0">
<span class="h2">New</span>
</p>
</div>
{{< /example >}}

## Accessibility

Since stickers only provide a container, accessibility becomes specific to the sticker content:
* [Showing and vocalizing prices](https://a11y-guidelines.orange.com/en/web/components-examples/price-vocalization) can help when stickers contain prices.
* [Accessibility and SVGs](https://a11y-guidelines.orange.com/en/articles/accessible-svg) can help with the SVGs.
* You must semantize the informative content in context with HTML elements, such as `<p>` (as shown in our examples), `<h1>` to `<h6>`, etc.

### Focus on one use case

{{< example >}}
<div class="sticker">
<p class="mb-1">
<span class="h3 mb-0 d-block text-decoration-line-through" aria-hidden="true">69.99 €</span>
<span class="display-3 mb-0 d-block" aria-hidden="true">39.99 €</span>
<span aria-hidden="true">Per month</span>
<span class="visually-hidden">39.99 € per month instead of 69.99 €</span>
</p>
</div>
{{< /example >}}

## Sass

### Variables

{{< scss-docs name="sticker" file="scss/_variables.scss" >}}
Loading

0 comments on commit b466b27

Please sign in to comment.