Skip to content

Commit 0bcaa16

Browse files
authored
Style glyphs for tree and accordion items (#30)
* Turn at 90deg the collapse glyph * Upgrade storybook * Use arrow glyph for accordion item * Prettify * Update snapshots * Expand one tree item in story for testing it * Update tree view snapshots
1 parent fdcf9c4 commit 0bcaa16

16 files changed

+478
-374
lines changed

packages/components/.eslintrc.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ module.exports = {
33
'eslint:recommended',
44
'plugin:@typescript-eslint/eslint-recommended',
55
'plugin:@typescript-eslint/recommended',
6-
'plugin:prettier/recommended'
6+
'plugin:prettier/recommended',
7+
'plugin:storybook/recommended'
78
],
89
parser: '@typescript-eslint/parser',
910
parserOptions: {
@@ -12,14 +13,22 @@ module.exports = {
1213
},
1314
plugins: ['@typescript-eslint'],
1415
rules: {
15-
'@typescript-eslint/no-unused-vars': ['warn', { args: 'none' }],
16+
'@typescript-eslint/no-unused-vars': [
17+
'warn',
18+
{
19+
args: 'none'
20+
}
21+
],
1622
'@typescript-eslint/no-explicit-any': 'off',
1723
'@typescript-eslint/no-namespace': 'off',
1824
'@typescript-eslint/no-use-before-define': 'off',
1925
'@typescript-eslint/quotes': [
2026
'error',
2127
'single',
22-
{ avoidEscape: true, allowTemplateLiterals: false }
28+
{
29+
avoidEscape: true,
30+
allowTemplateLiterals: false
31+
}
2332
],
2433
curly: ['error', 'all'],
2534
eqeqeq: 'error',

packages/components/package.json

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,21 @@
5555
"@rollup/plugin-commonjs": "^17.1.0",
5656
"@rollup/plugin-node-resolve": "^11.2.0",
5757
"@rollup/plugin-typescript": "^8.2.0",
58-
"@storybook/addon-a11y": "^6.4.3",
59-
"@storybook/addon-actions": "^6.4.3",
60-
"@storybook/addon-essentials": "^6.4.3",
61-
"@storybook/addon-links": "^6.4.3",
62-
"@storybook/addons": "^6.4.14",
63-
"@storybook/builder-webpack5": "^6.4.3",
64-
"@storybook/html": "^6.4.3",
65-
"@storybook/manager-webpack5": "^6.4.3",
66-
"@storybook/theming": "^6.4.3",
58+
"@storybook/addon-a11y": "^6.4.19",
59+
"@storybook/addon-actions": "^6.4.19",
60+
"@storybook/addon-essentials": "^6.4.19",
61+
"@storybook/addon-links": "^6.4.19",
62+
"@storybook/addons": "^6.4.19",
63+
"@storybook/builder-webpack5": "^6.4.19",
64+
"@storybook/html": "^6.4.19",
65+
"@storybook/manager-webpack5": "^6.4.19",
66+
"@storybook/theming": "^6.4.19",
6767
"@types/jest": "^27.0.0",
6868
"@typescript-eslint/eslint-plugin": "^4.8.1",
6969
"eslint": "^7.14.0",
7070
"eslint-config-prettier": "^6.15.0",
7171
"eslint-plugin-import": "^2.25.2",
72+
"eslint-plugin-storybook": "^0.5.7",
7273
"gh-pages": "^3.1.0",
7374
"jest": "^27.2.4",
7475
"prettier": "^2.2.1",

packages/components/src/accordion-item/accordion-item.styles.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
} from '@microsoft/fast-foundation';
1414
import { SystemColors } from '@microsoft/fast-web-utilities';
1515
import {
16-
accentFillRest,
1716
bodyFont,
1817
controlCornerRadius,
1918
density,
@@ -51,33 +50,33 @@ export const accordionItemStyles: FoundationElementTemplate<
5150
padding: calc((6 + (${designUnit} * 2 * ${density})) * 1px);
5251
}
5352
54-
.heading {
53+
div.heading {
5554
display: grid;
5655
position: relative;
57-
grid-template-columns: auto 1fr auto calc(${heightNumber} * 1px);
56+
grid-template-columns: calc(${heightNumber} * 1px) auto 1fr auto;
57+
color: ${neutralForegroundRest};
5858
}
5959
6060
.button {
6161
appearance: none;
6262
border: none;
6363
background: none;
64-
grid-column: 2;
65-
grid-row: 1;
64+
grid-column: 3;
6665
outline: none;
6766
padding: 0 calc((6 + (${designUnit} * 2 * ${density})) * 1px);
6867
text-align: left;
6968
height: calc(${heightNumber} * 1px);
70-
color: ${neutralForegroundRest};
69+
color: currentcolor;
7170
cursor: pointer;
7271
font-family: inherit;
7372
}
7473
7574
.button:hover {
76-
color: ${neutralForegroundRest};
75+
color: currentcolor;
7776
}
7877
7978
.button:active {
80-
color: ${neutralForegroundRest};
79+
color: currentcolor;
8180
}
8281
8382
.button::before {
@@ -105,14 +104,15 @@ export const accordionItemStyles: FoundationElementTemplate<
105104
display: flex;
106105
align-items: center;
107106
justify-content: center;
108-
grid-column: 4;
107+
grid-column: 1;
108+
grid-row: 1;
109109
pointer-events: none;
110110
position: relative;
111111
}
112112
113113
slot[name='expanded-icon'],
114114
slot[name='collapsed-icon'] {
115-
fill: ${accentFillRest};
115+
fill: currentcolor;
116116
}
117117
118118
slot[name='collapsed-icon'] {
@@ -136,15 +136,15 @@ export const accordionItemStyles: FoundationElementTemplate<
136136
align-items: center;
137137
padding-inline-start: calc(${designUnit} * 1px);
138138
justify-content: center;
139-
grid-column: 1;
139+
grid-column: 2;
140140
position: relative;
141141
}
142142
143143
.end {
144144
display: flex;
145145
align-items: center;
146146
justify-content: center;
147-
grid-column: 3;
147+
grid-column: 4;
148148
position: relative;
149149
}
150150
`.withBehaviors(

packages/components/src/accordion-item/index.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,30 @@ export const jpAccordionItem = AccordionItem.compose<AccordionItemOptions>({
2525
<svg
2626
width="20"
2727
height="20"
28-
viewBox="0 0 20 20"
28+
viewBox="0 0 16 16"
2929
xmlns="http://www.w3.org/2000/svg"
30+
class="expand-collapse-glyph"
3031
>
3132
<path
3233
fill-rule="evenodd"
3334
clip-rule="evenodd"
34-
d="M16.22 3H3.78a.78.78 0 00-.78.78v12.44c0 .43.35.78.78.78h12.44c.43 0 .78-.35.78-.78V3.78a.78.78 0 00-.78-.78zM3.78 2h12.44C17.2 2 18 2.8 18 3.78v12.44c0 .98-.8 1.78-1.78 1.78H3.78C2.8 18 2 17.2 2 16.22V3.78C2 2.8 2.8 2 3.78 2zM11 9h3v2h-3v3H9v-3H6V9h3V6h2v3z"
35+
d="M5.00001 12.3263C5.00124 12.5147 5.05566 12.699 5.15699 12.8578C5.25831 13.0167 5.40243 13.1437 5.57273 13.2242C5.74304 13.3047 5.9326 13.3354 6.11959 13.3128C6.30659 13.2902 6.4834 13.2152 6.62967 13.0965L10.8988 8.83532C11.0739 8.69473 11.2153 8.51658 11.3124 8.31402C11.4096 8.11146 11.46 7.88966 11.46 7.66499C11.46 7.44033 11.4096 7.21853 11.3124 7.01597C11.2153 6.81341 11.0739 6.63526 10.8988 6.49467L6.62967 2.22347C6.48274 2.10422 6.30501 2.02912 6.11712 2.00691C5.92923 1.9847 5.73889 2.01628 5.56823 2.09799C5.39757 2.17969 5.25358 2.30817 5.153 2.46849C5.05241 2.62882 4.99936 2.8144 5.00001 3.00369V12.3263Z"
3536
/>
3637
</svg>
3738
`,
3839
expandedIcon: /* html */ `
3940
<svg
4041
width="20"
4142
height="20"
42-
viewBox="0 0 20 20"
43+
viewBox="0 0 16 16"
4344
xmlns="http://www.w3.org/2000/svg"
45+
class="expand-collapse-glyph"
4446
>
4547
<path
4648
fill-rule="evenodd"
4749
clip-rule="evenodd"
48-
d="M3.78 3h12.44c.43 0 .78.35.78.78v12.44c0 .43-.35.78-.78.78H3.78a.78.78 0 01-.78-.78V3.78c0-.43.35-.78.78-.78zm12.44-1H3.78C2.8 2 2 2.8 2 3.78v12.44C2 17.2 2.8 18 3.78 18h12.44c.98 0 1.78-.8 1.78-1.78V3.78C18 2.8 17.2 2 16.22 2zM14 9H6v2h8V9z"
50+
transform="rotate(90,8,8)"
51+
d="M5.00001 12.3263C5.00124 12.5147 5.05566 12.699 5.15699 12.8578C5.25831 13.0167 5.40243 13.1437 5.57273 13.2242C5.74304 13.3047 5.9326 13.3354 6.11959 13.3128C6.30659 13.2902 6.4834 13.2152 6.62967 13.0965L10.8988 8.83532C11.0739 8.69473 11.2153 8.51658 11.3124 8.31402C11.4096 8.11146 11.46 7.88966 11.46 7.66499C11.46 7.44033 11.4096 7.21853 11.3124 7.01597C11.2153 6.81341 11.0739 6.63526 10.8988 6.49467L6.62967 2.22347C6.48274 2.10422 6.30501 2.02912 6.11712 2.00691C5.92923 1.9847 5.73889 2.01628 5.56823 2.09799C5.39757 2.17969 5.25358 2.30817 5.153 2.46849C5.05241 2.62882 4.99936 2.8144 5.00001 3.00369V12.3263Z"
4952
/>
5053
</svg>
5154
`

packages/components/src/tree-item/tree-item.styles.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const ltr = css`
5353
left: calc(${focusStrokeWidth} * 1px);
5454
}
5555
:host([expanded]) > .positioning-region .expand-collapse-glyph {
56-
transform: rotate(45deg);
56+
transform: rotate(90deg);
5757
}
5858
`;
5959

@@ -71,7 +71,7 @@ const rtl = css`
7171
right: calc(${focusStrokeWidth} * 1px);
7272
}
7373
:host([expanded]) > .positioning-region .expand-collapse-glyph {
74-
transform: rotate(135deg);
74+
transform: rotate(90deg);
7575
}
7676
`;
7777

packages/components/src/tree-view/tree-view.stories.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const Template = (
3939
<jp-tree-item>Nested item 2</jp-tree-item>
4040
<jp-tree-item>Nested item 3</jp-tree-item>
4141
</jp-tree-item>
42-
<jp-tree-item>
42+
<jp-tree-item expanded>
4343
Root item 2
4444
<jp-tree-item>
4545
Flowers

0 commit comments

Comments
 (0)