@1024pix/pix-ui 23.2.1 → 23.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/addon/components/pix-indicator-card.hbs +45 -0
- package/addon/components/pix-indicator-card.js +21 -0
- package/addon/styles/_pix-indicator-card.scss +65 -0
- package/addon/styles/addon.scss +1 -0
- package/addon/utils/accessible-contrasted-color-generator.js +29 -0
- package/app/components/pix-indicator-card.js +1 -0
- package/app/stories/pix-block.stories.mdx +3 -9
- package/app/stories/pix-indicator-card.stories.js +57 -0
- package/app/stories/pix-indicator-card.stories.mdx +38 -0
- package/package.json +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Pix-UI Changelog
|
|
2
2
|
|
|
3
|
+
## v23.3.0 (29/12/2022)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### :rocket: Amélioration
|
|
7
|
+
- [#307](https://github.com/1024pix/pix-ui/pull/307) [FEATURE] Création du composant carte (PIX-6141).
|
|
8
|
+
|
|
9
|
+
### :building_construction: Tech
|
|
10
|
+
- [#313](https://github.com/1024pix/pix-ui/pull/313) [TECH] Ne plus ajouter de lien vers la review-app dans la pull-request
|
|
11
|
+
|
|
3
12
|
## v23.2.1 (21/12/2022)
|
|
4
13
|
|
|
5
14
|
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<section class="indicator-card" ...attributes>
|
|
2
|
+
{{#if @isLoading}}
|
|
3
|
+
<p class="screen-reader-only">{{@loadingMessage}}</p>
|
|
4
|
+
<div class="indicator-card__icon" aria-hidden="true"></div>
|
|
5
|
+
<div class="indicator-card__content" aria-hidden="true"></div>
|
|
6
|
+
{{else}}
|
|
7
|
+
<div
|
|
8
|
+
id={{this.iconId}}
|
|
9
|
+
class="indicator-card__icon"
|
|
10
|
+
aria-hidden="true"
|
|
11
|
+
{{did-insert this.setIconColor}}
|
|
12
|
+
>
|
|
13
|
+
<FaIcon @icon={{@icon}} />
|
|
14
|
+
</div>
|
|
15
|
+
<dl class="indicator-card__content">
|
|
16
|
+
<div class="indicator-card__title">
|
|
17
|
+
<dt>{{@title}}</dt>
|
|
18
|
+
{{#if @info}}
|
|
19
|
+
<PixTooltip
|
|
20
|
+
@id={{this.tooltipId}}
|
|
21
|
+
@position="top"
|
|
22
|
+
@isWide={{true}}
|
|
23
|
+
class="indicator-card__tooltip hide-on-mobile"
|
|
24
|
+
>
|
|
25
|
+
<:triggerElement>
|
|
26
|
+
<FaIcon
|
|
27
|
+
@icon="circle-question"
|
|
28
|
+
class="indicator-card__tooltip-icon"
|
|
29
|
+
tabindex="0"
|
|
30
|
+
aria-describedby={{this.tooltipId}}
|
|
31
|
+
/>
|
|
32
|
+
</:triggerElement>
|
|
33
|
+
<:tooltip>
|
|
34
|
+
{{@info}}
|
|
35
|
+
</:tooltip>
|
|
36
|
+
</PixTooltip>
|
|
37
|
+
{{/if}}
|
|
38
|
+
</div>
|
|
39
|
+
<dd class="indicator-card__value">{{yield}}</dd>
|
|
40
|
+
<p class="indicator-card__sub">
|
|
41
|
+
{{yield to="sub"}}
|
|
42
|
+
</p>
|
|
43
|
+
</dl>
|
|
44
|
+
{{/if}}
|
|
45
|
+
</section>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { action } from '@ember/object';
|
|
3
|
+
import { guidFor } from '@ember/object/internals';
|
|
4
|
+
import accessibleContrastedColorGenerator from '@1024pix/pix-ui/utils/accessible-contrasted-color-generator';
|
|
5
|
+
|
|
6
|
+
export default class PixIndicatorCard extends Component {
|
|
7
|
+
id = guidFor(this);
|
|
8
|
+
iconId = 'icon-' + this.id;
|
|
9
|
+
tooltipId = 'tooltip-' + this.id;
|
|
10
|
+
|
|
11
|
+
@action
|
|
12
|
+
setIconColor() {
|
|
13
|
+
const element = document.getElementById(this.iconId);
|
|
14
|
+
try {
|
|
15
|
+
element.style.color = this.args.color;
|
|
16
|
+
element.style.backgroundColor = accessibleContrastedColorGenerator(this.args.color);
|
|
17
|
+
} catch (error) {
|
|
18
|
+
console.error(error.message);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
.indicator-card {
|
|
2
|
+
display: flex;
|
|
3
|
+
width: 100%;
|
|
4
|
+
background-color: $pix-neutral-0;
|
|
5
|
+
border-radius: 8px;
|
|
6
|
+
min-height: 112px;
|
|
7
|
+
|
|
8
|
+
box-shadow: 0 4px 8px rgba($pix-neutral-110, 0.05);
|
|
9
|
+
padding: 0;
|
|
10
|
+
|
|
11
|
+
&__icon {
|
|
12
|
+
display: flex;
|
|
13
|
+
justify-content: center;
|
|
14
|
+
align-items: center;
|
|
15
|
+
border-radius: 8px 0 0 8px;
|
|
16
|
+
background-color: $pix-neutral-20;
|
|
17
|
+
min-width: 96px;
|
|
18
|
+
font-size: 2.5rem;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&__content {
|
|
22
|
+
display: flex;
|
|
23
|
+
flex-direction: column;
|
|
24
|
+
justify-content: center;
|
|
25
|
+
color: $pix-neutral-60;
|
|
26
|
+
padding: $spacing-s $spacing-m;
|
|
27
|
+
margin: 0;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&__title {
|
|
31
|
+
@include text-large();
|
|
32
|
+
display: flex;
|
|
33
|
+
align-items: center;
|
|
34
|
+
font-weight: $font-medium;
|
|
35
|
+
font-size: 1rem;
|
|
36
|
+
line-height: 1.375rem;
|
|
37
|
+
margin-bottom: $spacing-xxs;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
&__value {
|
|
41
|
+
font-family: $font-open-sans;
|
|
42
|
+
font-weight: $font-medium;
|
|
43
|
+
font-size: 2rem;
|
|
44
|
+
line-height: 2.5rem;
|
|
45
|
+
margin: 0;
|
|
46
|
+
margin-bottom: $spacing-xxs;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
&__sub {
|
|
50
|
+
@include text-small();
|
|
51
|
+
font-weight: $font-normal;
|
|
52
|
+
display: flex;
|
|
53
|
+
gap: 10px;
|
|
54
|
+
margin: 0
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
&__tooltip {
|
|
58
|
+
font-weight: $font-normal;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
&__tooltip-icon {
|
|
62
|
+
color: $pix-neutral-30;
|
|
63
|
+
margin: 0 $spacing-xs;
|
|
64
|
+
}
|
|
65
|
+
}
|
package/addon/styles/addon.scss
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import Color from 'color';
|
|
2
|
+
|
|
3
|
+
// See this link that explains why we had to implement lightenBy and darkenBy https://github.com/Qix-/color/issues/53#issuecomment-487822576
|
|
4
|
+
function lightenBy(color, ratio) {
|
|
5
|
+
const lightness = color.lightness();
|
|
6
|
+
return color.lightness(lightness + (100 - lightness) * ratio);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function darkenBy(color, ratio) {
|
|
10
|
+
const lightness = color.lightness();
|
|
11
|
+
return color.lightness(lightness - lightness * ratio);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default function (hex) {
|
|
15
|
+
const color = Color(hex);
|
|
16
|
+
let newColor = color;
|
|
17
|
+
let contrast;
|
|
18
|
+
do {
|
|
19
|
+
if (color.luminosity() < 0.5) {
|
|
20
|
+
newColor = lightenBy(newColor, 0.05);
|
|
21
|
+
} else {
|
|
22
|
+
newColor = darkenBy(newColor, 0.05);
|
|
23
|
+
}
|
|
24
|
+
contrast = color.contrast(newColor);
|
|
25
|
+
|
|
26
|
+
// newColor.luminosity() can return 0.9999..99 when newColor is white but reinstanciating Color with the hexacode #FFFFFF returns 1
|
|
27
|
+
} while (contrast < 4.5 && Color(newColor.hex()).luminosity() < 1);
|
|
28
|
+
return newColor.hex();
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@1024pix/pix-ui/components/pix-indicator-card';
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import { Meta, Story, Canvas, ArgsTable } from '@storybook/addon-docs/blocks';
|
|
2
2
|
import * as stories from './pix-block.stories.js';
|
|
3
3
|
|
|
4
|
-
<Meta
|
|
5
|
-
title='Layout/Block'
|
|
6
|
-
component='PixBlock'
|
|
7
|
-
argTypes={stories.argTypes}
|
|
8
|
-
/>
|
|
4
|
+
<Meta title="Layout/Block" component="PixBlock" argTypes={stories.argTypes} />
|
|
9
5
|
|
|
10
6
|
# Pix Block
|
|
11
7
|
|
|
@@ -21,18 +17,16 @@ Un \`Block\` est un bloc de fond blanc dont les bords sont arrondis et ayant une
|
|
|
21
17
|
<Story name="Block" story={stories.block} height={60} />
|
|
22
18
|
</Canvas>
|
|
23
19
|
|
|
24
|
-
|
|
25
20
|
## Usage
|
|
26
21
|
|
|
27
22
|
```html
|
|
28
23
|
<PixBlock @shadow="light">
|
|
29
|
-
<div>
|
|
24
|
+
<div>Un bloc avec une ombre faible</div>
|
|
30
25
|
</PixBlock>
|
|
31
26
|
|
|
32
27
|
<PixBlock @shadow="heavy">
|
|
33
|
-
<div>
|
|
28
|
+
<div>Un bloc avec une ombre forte</div>
|
|
34
29
|
</PixBlock>
|
|
35
|
-
|
|
36
30
|
```
|
|
37
31
|
|
|
38
32
|
## Arguments
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { hbs } from 'ember-cli-htmlbars';
|
|
2
|
+
|
|
3
|
+
const Template = (args) => {
|
|
4
|
+
return {
|
|
5
|
+
template: hbs`
|
|
6
|
+
<div style="min-width:300px">
|
|
7
|
+
<PixIndicatorCard
|
|
8
|
+
@title={{this.title}}
|
|
9
|
+
@color={{this.color}}
|
|
10
|
+
@icon={{this.icon}}
|
|
11
|
+
@info={{this.info}}
|
|
12
|
+
@isLoading={{this.isLoading}}
|
|
13
|
+
@loadingMessage={{this.loadingMessage}}
|
|
14
|
+
>
|
|
15
|
+
<:default>{{this.value}}</:default>
|
|
16
|
+
<:sub>
|
|
17
|
+
<span>En cours : 1</span><span>En attente : 2</span><span>Envoyés : 3</span>
|
|
18
|
+
</:sub>
|
|
19
|
+
</PixIndicatorCard>
|
|
20
|
+
</div>`,
|
|
21
|
+
context: args,
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const Default = Template.bind({});
|
|
26
|
+
Default.args = {
|
|
27
|
+
title: 'Hello Dedans',
|
|
28
|
+
color: 'purple',
|
|
29
|
+
icon: 'circle-question',
|
|
30
|
+
value: '42',
|
|
31
|
+
info: "Coucou la bulle d'infos",
|
|
32
|
+
isLoading: false,
|
|
33
|
+
loadingMessage: 'texte de chargement ScreenReader',
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const argTypes = {
|
|
37
|
+
title: {
|
|
38
|
+
name: 'Title',
|
|
39
|
+
description: 'Titre de la carte',
|
|
40
|
+
},
|
|
41
|
+
color: {
|
|
42
|
+
name: 'Color',
|
|
43
|
+
description: "Couleur de l'icone",
|
|
44
|
+
},
|
|
45
|
+
icon: {
|
|
46
|
+
name: 'Icon',
|
|
47
|
+
description: "Icone dans l'encart",
|
|
48
|
+
},
|
|
49
|
+
value: {
|
|
50
|
+
name: 'Value',
|
|
51
|
+
description: 'Contenu principal',
|
|
52
|
+
},
|
|
53
|
+
info: {
|
|
54
|
+
name: 'Info',
|
|
55
|
+
description: "Contenu de la bulle d'info",
|
|
56
|
+
},
|
|
57
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Meta, Story, Canvas, ArgsTable } from '@storybook/addon-docs/blocks';
|
|
2
|
+
import * as stories from './pix-indicator-card.stories.js';
|
|
3
|
+
|
|
4
|
+
<Meta title="Others/Indicator Card" component="PixIndicatorCard" argTypes={stories.argTypes} />
|
|
5
|
+
|
|
6
|
+
# Pix Indicator Card
|
|
7
|
+
|
|
8
|
+
Une carte est un bloc en 2 parties dont les bords sont arrondis et ayant une ombre projetée.
|
|
9
|
+
|
|
10
|
+
> La carte adapte la couleur de fond avec la couleur de l'icone passée en paramètre.
|
|
11
|
+
|
|
12
|
+
> La carte peut contenir un titre, une tooltip ainsi que des infos complémentaires.
|
|
13
|
+
|
|
14
|
+
## Default
|
|
15
|
+
|
|
16
|
+
<Canvas>
|
|
17
|
+
<Story name="Default" story={stories.Default} height={200} />
|
|
18
|
+
</Canvas>
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
```html
|
|
23
|
+
<PixIndicatorCard
|
|
24
|
+
@title={{this.title}}
|
|
25
|
+
@color={{this.color}}
|
|
26
|
+
@icon={{this.icon}}
|
|
27
|
+
@info={{this.info}}
|
|
28
|
+
@isLoading={{this.isLoading}}
|
|
29
|
+
@loadingMessage={{this.loadingMessage}}
|
|
30
|
+
>
|
|
31
|
+
<:default>{{this.value}}</:default>
|
|
32
|
+
<:sub>
|
|
33
|
+
<span>En cours : 1</span><span>En attente : 2</span><span>Envoyés : 3</span>
|
|
34
|
+
</:sub>
|
|
35
|
+
</PixIndicatorCard>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
<ArgsTable story="Default" />
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1024pix/pix-ui",
|
|
3
|
-
"version": "23.
|
|
3
|
+
"version": "23.3.0",
|
|
4
4
|
"description": "Pix-UI is the implementation of Pix design principles and guidelines for its products.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"test": "tests"
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
|
-
"build": "./scripts/build.sh
|
|
26
|
+
"build": "./scripts/build.sh",
|
|
27
27
|
"build-ember": "ember build --environment=production",
|
|
28
28
|
"build-storybook": "ember build && cp -v CNAME dist && build-storybook -s dist",
|
|
29
29
|
"clean": "rm -rf dist node_modules",
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
"storybook": "ember build && ember serve & start-storybook -p 9001 -s dist",
|
|
40
40
|
"test": "ember test",
|
|
41
41
|
"test:ember": "ember test",
|
|
42
|
-
"test:ember-compatibility": "ember try:each"
|
|
43
|
-
"signal-github": "./scripts/signal-deploy-to-pr.sh"
|
|
42
|
+
"test:ember-compatibility": "ember try:each"
|
|
44
43
|
},
|
|
45
44
|
"dependencies": {
|
|
45
|
+
"color": "^4.2.3",
|
|
46
46
|
"ember-cli-babel": "^7.26.8",
|
|
47
47
|
"ember-cli-htmlbars": "^6.1.1",
|
|
48
48
|
"ember-cli-sass": "^11.0.1",
|
|
@@ -82,6 +82,7 @@
|
|
|
82
82
|
"core-js": "^3.26.1",
|
|
83
83
|
"ember-auto-import": "^2.5.0",
|
|
84
84
|
"ember-cli": "^4.8.0",
|
|
85
|
+
"ember-cli-cjs-transform": "^2.0.0",
|
|
85
86
|
"ember-cli-dependency-checker": "^3.3.1",
|
|
86
87
|
"ember-cli-inject-live-reload": "^2.1.0",
|
|
87
88
|
"ember-cli-sri": "^2.1.1",
|