Skip to content

Commit 7e464f6

Browse files
jenndiazpfulton
andauthored
feat(thumbnail): add whcm for layer variants (#2254)
* feat(thumbnail): add whcm for layer variants * feat(thumbnail): add isFocused on storybook * chore(thumbnail): format css * Revert "chore(thumbnail): format css" This reverts commit 1520d6a. * chore(thumbnail): cleans up css * fix(thumbnail): resolve storybook rendering errors --------- Co-authored-by: Patrick Fulton <[email protected]>
1 parent f2528e5 commit 7e464f6

File tree

3 files changed

+96
-9
lines changed

3 files changed

+96
-9
lines changed

components/thumbnail/index.css

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,18 @@ governing permissions and limitations under the License.
207207
}
208208

209209
.spectrum-Thumbnail-layer {
210-
border: var(--mod-thumbnail-layer-border-width-outer, var(--spectrum-thumbnail-layer-border-width-outer)) solid var(--mod-thumbnail-layer-border-color-outer, var(--spectrum-thumbnail-layer-border-color-outer));
210+
border-style: solid;
211+
border-width: var(
212+
--mod-thumbnail-layer-border-width-outer,
213+
var(--spectrum-thumbnail-layer-border-width-outer)
214+
);
215+
border-color: var(
216+
--highcontrast-thumbnail-layer-border-color-outer,
217+
var(
218+
--mod-thumbnail-layer-border-color-outer,
219+
var(--spectrum-thumbnail-layer-border-color-outer)
220+
)
221+
);
211222
box-sizing: border-box;
212223

213224
display: flex;
@@ -274,8 +285,11 @@ governing permissions and limitations under the License.
274285
);
275286
outline-style: solid;
276287
outline-color: var(
277-
--mod-thumbnail-layer-border-color-inner,
278-
var(--spectrum-thumbnail-layer-border-color-inner)
288+
--highcontrast-thumbnail-layer-border-color-inner,
289+
var(
290+
--mod-thumbnail-layer-border-color-inner,
291+
var(--spectrum-thumbnail-layer-border-color-inner)
292+
)
279293
);
280294
outline-width: calc(
281295
var(
@@ -329,17 +343,14 @@ governing permissions and limitations under the License.
329343
}
330344

331345
/* Windows High Contrast Mode */
332-
/* stylelint-disable declaration-property-value-no-unknown */
333346
@media (forced-colors: active) {
334347
.spectrum-Thumbnail {
335348
/* Allow checkerboard pattern to be visible. */
336349
forced-color-adjust: none;
337-
338-
--highcontrast-thumbnail-border-color-selected: SelectedItem;
350+
--highcontrast-thumbnail-border-color-selected: Highlight;
339351
--highcontrast-thumbnail-focus-indicator-color: Highlight;
340352
--highcontrast-thumbnail-border-color: CanvasText;
341-
background-color: Canvas;
342-
color: CanvasText;
353+
--highcontrast-thumbnail-layer-border-color-inner: Canvas;
354+
--highcontrast-thumbnail-layer-border-color-outer: CanvasText;
343355
}
344356
}
345-
/* stylelint-enable declaration-property-value-no-unknown */

components/thumbnail/stories/template.js

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,72 @@ export const Template = ({
2727

2828
const image = imageURL ? html`<img class="${rootClass}-image" src=${imageURL} alt=${ifDefined(altText)}/>` : svg ? html`${svg}` : "";
2929

30+
const checkerboardContent = html`
31+
<div class="${rootClass}-image-wrapper">
32+
${imageURL
33+
? html`<img
34+
class="${rootClass}-image"
35+
src=${imageURL}
36+
alt=${altText}
37+
/>`
38+
: ""}
39+
${svg ? html`${svg}` : ""}
40+
</div>
41+
`;
42+
43+
if (isLayer)
44+
return html`
45+
<div
46+
class=${classMap({
47+
[rootClass]: true,
48+
[`${rootClass}--cover`]: isCover,
49+
[`${rootClass}-layer`]: isLayer,
50+
[`is-selected`]: isSelected,
51+
[`is-disabled`]: isDisabled,
52+
[`is-focused`]: isFocused,
53+
[`${rootClass}--size${size}`]: typeof size !== "undefined",
54+
...customClasses.reduce((a, c) => ({ ...a, [c]: true }), {}),
55+
})}
56+
id=${ifDefined(id)}
57+
@click=${onclick}
58+
>
59+
${OpacityCheckerboard({
60+
componentOnly: true,
61+
customClasses: [`${rootClass}-layer-inner`],
62+
content: checkerboardContent,
63+
})}
64+
</div>
65+
`;
66+
67+
if (backgroundColor)
68+
return html`
69+
<div
70+
class=${classMap({
71+
[rootClass]: true,
72+
[`${rootClass}--cover`]: isCover,
73+
[`${rootClass}-layer`]: isLayer,
74+
[`is-selected`]: isSelected,
75+
[`is-disabled`]: isDisabled,
76+
[`is-focused`]: isFocused,
77+
[`${rootClass}--size${size}`]: typeof size !== "undefined",
78+
...customClasses.reduce((a, c) => ({ ...a, [c]: true }), {}),
79+
})}
80+
id=${ifDefined(id)}
81+
@click=${onclick}
82+
>
83+
<div class="${rootClass}-background" style=${styleMap({backgroundColor})}></div>
84+
<div class="${rootClass}-image-wrapper">
85+
${imageURL
86+
? html`<img
87+
class="${rootClass}-image"
88+
src=${imageURL}
89+
alt=${altText}
90+
/>`
91+
: ""}
92+
</div>
93+
</div>
94+
`;
95+
3096
return html`
3197
<div
3298
class=${classMap({

components/thumbnail/stories/thumbnail.stories.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,15 @@ export default {
101101
control: "boolean",
102102
if: { arg: "isLayer" },
103103
},
104+
isFocused: {
105+
name: "Focused",
106+
type: { name: "boolean" },
107+
table: {
108+
type: { summary: "boolean" },
109+
category: "State",
110+
},
111+
control: "boolean",
112+
},
104113
},
105114
args: {
106115
rootClass: "spectrum-Thumbnail",
@@ -109,6 +118,7 @@ export default {
109118
isLayer: false,
110119
isDisabled: false,
111120
isSelected: false,
121+
isFocused: false,
112122
imageURL: "example-card-landscape.png",
113123
altText: "Landscape with mountains and lake",
114124
},

0 commit comments

Comments
 (0)