@workday/canvas-kit-labs-react 16.2.0-0652-next.0 → 16.2.0-0654-next.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/accessory/index.ts +6 -0
- package/accessory/lib/Accessory.tsx +156 -0
- package/accessory/lib/AccessoryCalendar.tsx +114 -0
- package/accessory/lib/AccessoryFavicon.tsx +156 -0
- package/accessory/lib/AccessoryFile.tsx +140 -0
- package/accessory/lib/AccessoryIcon.tsx +213 -0
- package/accessory/lib/AccessoryMedia.tsx +142 -0
- package/accessory/package.json +6 -0
- package/dist/commonjs/accessory/index.d.ts +7 -0
- package/dist/commonjs/accessory/index.d.ts.map +1 -0
- package/dist/commonjs/accessory/index.js +22 -0
- package/dist/commonjs/accessory/lib/Accessory.d.ts +157 -0
- package/dist/commonjs/accessory/lib/Accessory.d.ts.map +1 -0
- package/dist/commonjs/accessory/lib/Accessory.js +51 -0
- package/dist/commonjs/accessory/lib/AccessoryCalendar.d.ts +80 -0
- package/dist/commonjs/accessory/lib/AccessoryCalendar.d.ts.map +1 -0
- package/dist/commonjs/accessory/lib/AccessoryCalendar.js +48 -0
- package/dist/commonjs/accessory/lib/AccessoryFavicon.d.ts +75 -0
- package/dist/commonjs/accessory/lib/AccessoryFavicon.d.ts.map +1 -0
- package/dist/commonjs/accessory/lib/AccessoryFavicon.js +74 -0
- package/dist/commonjs/accessory/lib/AccessoryFile.d.ts +65 -0
- package/dist/commonjs/accessory/lib/AccessoryFile.d.ts.map +1 -0
- package/dist/commonjs/accessory/lib/AccessoryFile.js +58 -0
- package/dist/commonjs/accessory/lib/AccessoryIcon.d.ts +119 -0
- package/dist/commonjs/accessory/lib/AccessoryIcon.d.ts.map +1 -0
- package/dist/commonjs/accessory/lib/AccessoryIcon.js +61 -0
- package/dist/commonjs/accessory/lib/AccessoryMedia.d.ts +72 -0
- package/dist/commonjs/accessory/lib/AccessoryMedia.d.ts.map +1 -0
- package/dist/commonjs/accessory/lib/AccessoryMedia.js +59 -0
- package/dist/commonjs/index.d.ts +1 -0
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +1 -0
- package/dist/es6/accessory/index.d.ts +7 -0
- package/dist/es6/accessory/index.d.ts.map +1 -0
- package/dist/es6/accessory/index.js +6 -0
- package/dist/es6/accessory/lib/Accessory.d.ts +157 -0
- package/dist/es6/accessory/lib/Accessory.d.ts.map +1 -0
- package/dist/es6/accessory/lib/Accessory.js +48 -0
- package/dist/es6/accessory/lib/AccessoryCalendar.d.ts +80 -0
- package/dist/es6/accessory/lib/AccessoryCalendar.d.ts.map +1 -0
- package/dist/es6/accessory/lib/AccessoryCalendar.js +45 -0
- package/dist/es6/accessory/lib/AccessoryFavicon.d.ts +75 -0
- package/dist/es6/accessory/lib/AccessoryFavicon.d.ts.map +1 -0
- package/dist/es6/accessory/lib/AccessoryFavicon.js +71 -0
- package/dist/es6/accessory/lib/AccessoryFile.d.ts +65 -0
- package/dist/es6/accessory/lib/AccessoryFile.d.ts.map +1 -0
- package/dist/es6/accessory/lib/AccessoryFile.js +55 -0
- package/dist/es6/accessory/lib/AccessoryIcon.d.ts +119 -0
- package/dist/es6/accessory/lib/AccessoryIcon.d.ts.map +1 -0
- package/dist/es6/accessory/lib/AccessoryIcon.js +58 -0
- package/dist/es6/accessory/lib/AccessoryMedia.d.ts +72 -0
- package/dist/es6/accessory/lib/AccessoryMedia.d.ts.map +1 -0
- package/dist/es6/accessory/lib/AccessoryMedia.js +53 -0
- package/dist/es6/index.d.ts +1 -0
- package/dist/es6/index.d.ts.map +1 -1
- package/dist/es6/index.js +1 -0
- package/index.ts +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createComponent } from '@workday/canvas-kit-react/common';
|
|
3
|
+
import { createStencil, cssVar, handleCsProp, px2rem } from '@workday/canvas-kit-styling';
|
|
4
|
+
import { system } from '@workday/canvas-tokens-web';
|
|
5
|
+
import { Accessory, accessoryStencil } from './Accessory';
|
|
6
|
+
/** Hostname from a site URL or a bare domain such as `workday.com`. */
|
|
7
|
+
function hostnameFromSiteUrl(siteUrl) {
|
|
8
|
+
const trimmed = siteUrl.trim();
|
|
9
|
+
if (!trimmed) {
|
|
10
|
+
return '';
|
|
11
|
+
}
|
|
12
|
+
try {
|
|
13
|
+
const withProtocol = /^[a-z][a-z0-9+.-]*:\/\//i.test(trimmed) ? trimmed : `https://${trimmed}`;
|
|
14
|
+
return new URL(withProtocol).hostname || '';
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return '';
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Brand favicon URL for a site, resolved through the public Google favicon endpoint. Tiles larger
|
|
22
|
+
* than 32px request a 180px source. Smaller tiles request 64px.
|
|
23
|
+
*/
|
|
24
|
+
function faviconSrcFromSiteUrl(siteUrl, size) {
|
|
25
|
+
const host = hostnameFromSiteUrl(siteUrl);
|
|
26
|
+
if (!host) {
|
|
27
|
+
return '';
|
|
28
|
+
}
|
|
29
|
+
const sourceSize = size === 'extraLarge' ? 180 : 64;
|
|
30
|
+
return `https://www.google.com/s2/favicons?domain=${encodeURIComponent(host)}&sz=${sourceSize}`;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Favicon treatment for `AccessoryFavicon`. At `large` and `extraLarge` the mark is inset in an
|
|
34
|
+
* outlined tile. At `medium` and smaller the mark fills the tile and the frame is removed.
|
|
35
|
+
* `background` overrides the tile fill.
|
|
36
|
+
*/
|
|
37
|
+
export const accessoryFaviconStencil = createStencil({
|
|
38
|
+
parts: {
|
|
39
|
+
icon: 'accessory-icon',
|
|
40
|
+
image: 'accessory-favicon-image',
|
|
41
|
+
},
|
|
42
|
+
base: { name: "ddeax", styles: "box-sizing:border-box;[data-part=\"accessory-icon\"]{overflow:hidden;background-color:var(--tileBackground-accessory-05fc46, var(--cnvs-sys-color-surface-default, var(--cnvs-sys-color-bg-default, oklch(1 0 0 / 1))));border-width:0.0625rem;border-style:solid;border-color:var(--cnvs-sys-color-border-default, var(--cnvs-sys-color-border-divider, oklch(0.3057 0.079 256.22 / 0.13)));}[data-part=\"accessory-favicon-image\"]{width:calc(100% - var(--cnvs-sys-padding-sm, var(--cnvs-sys-space-x3, 0.75rem)));height:calc(100% - var(--cnvs-sys-padding-sm, var(--cnvs-sys-space-x3, 0.75rem)));object-fit:contain;border-radius:var(--cnvs-sys-shape-md, var(--cnvs-sys-shape-x2, 0.5rem));corner-shape:superellipse(1.1);}" },
|
|
43
|
+
modifiers: {
|
|
44
|
+
size: {
|
|
45
|
+
extraSmall: { name: "eynmi", styles: "[data-part=\"accessory-icon\"]{background-color:var(--tileBackground-accessory-05fc46, transparent);border-width:0;}[data-part=\"accessory-favicon-image\"]{width:100%;height:100%;border-radius:0;}" },
|
|
46
|
+
small: { name: "2xu3hy", styles: "[data-part=\"accessory-icon\"]{background-color:var(--tileBackground-accessory-05fc46, transparent);border-width:0;}[data-part=\"accessory-favicon-image\"]{width:100%;height:100%;border-radius:0;}" },
|
|
47
|
+
medium: { name: "3i8u7e", styles: "[data-part=\"accessory-icon\"]{background-color:var(--tileBackground-accessory-05fc46, transparent);border-width:0;}[data-part=\"accessory-favicon-image\"]{width:100%;height:100%;border-radius:0;}" },
|
|
48
|
+
large: { name: "15m46v", styles: "" },
|
|
49
|
+
extraLarge: { name: "4x5si", styles: "" }
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
defaultModifiers: {
|
|
53
|
+
size: 'extraLarge',
|
|
54
|
+
}
|
|
55
|
+
}, "accessory-favicon-77a3ef");
|
|
56
|
+
/**
|
|
57
|
+
* `AccessoryFavicon` renders a site favicon in an accessory tile. Pass a site URL or domain as
|
|
58
|
+
* `url`. The mark is inset in an outlined frame at `large` and `extraLarge`, and fills the tile at
|
|
59
|
+
* smaller sizes. Always decorative.
|
|
60
|
+
*
|
|
61
|
+
* The image is requested from the user's browser at `https://www.google.com/s2/favicons`. Google
|
|
62
|
+
* receives the hostname and the user's IP address. `referrerPolicy="no-referrer"` keeps the app
|
|
63
|
+
* origin off that request. It does not proxy the request.
|
|
64
|
+
*/
|
|
65
|
+
export const AccessoryFavicon = createComponent('span')({
|
|
66
|
+
displayName: 'AccessoryFavicon',
|
|
67
|
+
Component: ({ url, size = 'extraLarge', background, ...elemProps }, ref, Element) => {
|
|
68
|
+
const src = faviconSrcFromSiteUrl(url, size);
|
|
69
|
+
return (_jsx(Accessory, { as: Element, ref: ref, background: background, size: size, ...handleCsProp(elemProps, accessoryFaviconStencil({ size })), children: src ? (_jsx("span", { ...accessoryStencil.parts.icon, children: _jsx("img", { alt: "", src: src, ...accessoryFaviconStencil.parts.image, referrerPolicy: "no-referrer" }) })) : null }));
|
|
70
|
+
},
|
|
71
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { AccessoryProps } from './Accessory';
|
|
2
|
+
/**
|
|
3
|
+
* The kind of file `AccessoryFile` represents.
|
|
4
|
+
*/
|
|
5
|
+
export type AccessoryFileType = 'pdf' | 'spreadsheet' | 'document' | 'presentation' | 'video' | 'file' | 'txt';
|
|
6
|
+
export interface AccessoryFileProps extends AccessoryProps {
|
|
7
|
+
/**
|
|
8
|
+
* The file type. Chooses the glyph and sets the tile fill and icon color through a stencil
|
|
9
|
+
* modifier. Colored types keep their accent fill at every size. `file` and `txt` use
|
|
10
|
+
* `surface.alt` with a `border.default` stroke. `video` uses `surface.alt` and an inverse icon.
|
|
11
|
+
* `color` and `background` override the type colors.
|
|
12
|
+
* @default 'file'
|
|
13
|
+
*/
|
|
14
|
+
type?: AccessoryFileType;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* File-type treatment for `AccessoryFile`. Each `type` sets the tile fill and icon color.
|
|
18
|
+
* `outline` adds the default border used by `file` and `txt`. `color` and `background` on
|
|
19
|
+
* `Accessory` still override the type colors.
|
|
20
|
+
*/
|
|
21
|
+
export declare const accessoryFileStencil: import("@workday/canvas-kit-styling").Stencil<{
|
|
22
|
+
type: {
|
|
23
|
+
pdf: {
|
|
24
|
+
[x: string]: "--cnvs-sys-color-fg-inverse" | "var(--cnvs-sys-color-accent-danger, var(--cnvs-sys-color-bg-critical-default, oklch(0.5342 0.2172 29.53 / 1)))";
|
|
25
|
+
};
|
|
26
|
+
spreadsheet: {
|
|
27
|
+
[x: string]: "--cnvs-sys-color-fg-inverse" | "var(--cnvs-sys-color-accent-success, var(--cnvs-sys-color-bg-positive-default, oklch(0.5069 0.1569 145.56 / 1)))";
|
|
28
|
+
};
|
|
29
|
+
document: {
|
|
30
|
+
[x: string]: "--cnvs-sys-color-fg-inverse" | "var(--cnvs-sys-color-accent-info, var(--cnvs-sys-color-bg-info-default, oklch(0.5198 0.1782 256.11 / 1)))";
|
|
31
|
+
};
|
|
32
|
+
presentation: {
|
|
33
|
+
[x: string]: "var(--cnvs-sys-color-accent-contrast, oklch(0.0969 0 0 / 0.84))" | "var(--cnvs-sys-color-accent-warning, oklch(0.7909 0.1711 70.15 / 1))";
|
|
34
|
+
};
|
|
35
|
+
video: {
|
|
36
|
+
[x: string]: "var(--cnvs-sys-color-surface-alt-default, var(--cnvs-sys-color-bg-alt-soft, oklch(0.3343 0.0951 253.3 / 0.05)))" | "--cnvs-sys-color-fg-default";
|
|
37
|
+
};
|
|
38
|
+
file: {
|
|
39
|
+
[x: string]: "var(--cnvs-sys-color-surface-alt-default, var(--cnvs-sys-color-bg-alt-soft, oklch(0.3343 0.0951 253.3 / 0.05)))" | "--cnvs-sys-color-fg-default";
|
|
40
|
+
};
|
|
41
|
+
txt: {
|
|
42
|
+
[x: string]: "var(--cnvs-sys-color-surface-alt-default, var(--cnvs-sys-color-bg-alt-soft, oklch(0.3343 0.0951 253.3 / 0.05)))" | "--cnvs-sys-color-fg-default";
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
outline: {
|
|
46
|
+
true: ({ iconPart }: {} & import("@workday/canvas-kit-styling").StencilVarsParts<{
|
|
47
|
+
readonly icon: "accessory-icon";
|
|
48
|
+
}>) => {
|
|
49
|
+
"[data-part=\"accessory-icon\"]": {
|
|
50
|
+
borderWidth: string;
|
|
51
|
+
borderStyle: string;
|
|
52
|
+
borderColor: "var(--cnvs-sys-color-border-default, var(--cnvs-sys-color-border-divider, oklch(0.3057 0.079 256.22 / 0.13)))";
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
}, {
|
|
57
|
+
readonly icon: "accessory-icon";
|
|
58
|
+
}, {}, never, never>;
|
|
59
|
+
/**
|
|
60
|
+
* `AccessoryFile` renders a file-type tile. `type` chooses the glyph and sets the fill and icon
|
|
61
|
+
* color. Colored types keep their fill at every size. Generic file and text use `surface.alt` and
|
|
62
|
+
* a `border.default` stroke. Always decorative.
|
|
63
|
+
*/
|
|
64
|
+
export declare const AccessoryFile: import("@workday/canvas-kit-react/common").ElementComponent<"span", AccessoryFileProps>;
|
|
65
|
+
//# sourceMappingURL=AccessoryFile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccessoryFile.d.ts","sourceRoot":"","sources":["../../../../accessory/lib/AccessoryFile.tsx"],"names":[],"mappings":"AAaA,OAAO,EAAY,cAAc,EAAmB,MAAM,aAAa,CAAC;AAExE;;GAEG;AACH,MAAM,MAAM,iBAAiB,GACzB,KAAK,GACL,aAAa,GACb,UAAU,GACV,cAAc,GACd,OAAO,GACP,MAAM,GACN,KAAK,CAAC;AAEV,MAAM,WAAW,kBAAmB,SAAQ,cAAc;IACxD;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,iBAAiB,CAAC;CAC1B;AAED;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAwD/B,CAAC;AAYH;;;;GAIG;AACH,eAAO,MAAM,aAAa,yFAuBxB,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createComponent } from '@workday/canvas-kit-react/common';
|
|
3
|
+
import { SystemIcon, systemIconStencil } from '@workday/canvas-kit-react/icon';
|
|
4
|
+
import { createStencil, cssVar, handleCsProp, px2rem } from '@workday/canvas-kit-styling';
|
|
5
|
+
import { documentIcon, pdfIcon, playCircleIcon, stackIcon, tableExpandIcon, txtIcon, } from '@workday/canvas-system-icons-web';
|
|
6
|
+
import { system } from '@workday/canvas-tokens-web';
|
|
7
|
+
import { Accessory, accessoryStencil } from './Accessory';
|
|
8
|
+
/**
|
|
9
|
+
* File-type treatment for `AccessoryFile`. Each `type` sets the tile fill and icon color.
|
|
10
|
+
* `outline` adds the default border used by `file` and `txt`. `color` and `background` on
|
|
11
|
+
* `Accessory` still override the type colors.
|
|
12
|
+
*/
|
|
13
|
+
export const accessoryFileStencil = createStencil({
|
|
14
|
+
parts: {
|
|
15
|
+
icon: 'accessory-icon',
|
|
16
|
+
},
|
|
17
|
+
base: { name: "3ruv0p", styles: "box-sizing:border-box;[data-part=\"accessory-icon\"]{background-color:var(--tileBackground-accessory-05fc46);--color-system-icon-c9acc3:var(--iconColor-accessory-05fc46);}" },
|
|
18
|
+
modifiers: {
|
|
19
|
+
type: {
|
|
20
|
+
pdf: { name: "2e8yi0", styles: "--iconColor-accessory-05fc46:var(--cnvs-sys-color-fg-inverse);--tileBackground-accessory-05fc46:var(--cnvs-sys-color-accent-danger, var(--cnvs-sys-color-bg-critical-default, oklch(0.5342 0.2172 29.53 / 1)));" },
|
|
21
|
+
spreadsheet: { name: "3mdjnf", styles: "--iconColor-accessory-05fc46:var(--cnvs-sys-color-fg-inverse);--tileBackground-accessory-05fc46:var(--cnvs-sys-color-accent-success, var(--cnvs-sys-color-bg-positive-default, oklch(0.5069 0.1569 145.56 / 1)));" },
|
|
22
|
+
document: { name: "1cn0a8", styles: "--iconColor-accessory-05fc46:var(--cnvs-sys-color-fg-inverse);--tileBackground-accessory-05fc46:var(--cnvs-sys-color-accent-info, var(--cnvs-sys-color-bg-info-default, oklch(0.5198 0.1782 256.11 / 1)));" },
|
|
23
|
+
presentation: { name: "1twrf1", styles: "--iconColor-accessory-05fc46:var(--cnvs-sys-color-accent-contrast, oklch(0.0969 0 0 / 0.84));--tileBackground-accessory-05fc46:var(--cnvs-sys-color-accent-warning, oklch(0.7909 0.1711 70.15 / 1));" },
|
|
24
|
+
video: { name: "sgf0d", styles: "--iconColor-accessory-05fc46:var(--cnvs-sys-color-fg-default);--tileBackground-accessory-05fc46:var(--cnvs-sys-color-surface-alt-default, var(--cnvs-sys-color-bg-alt-soft, oklch(0.3343 0.0951 253.3 / 0.05)));" },
|
|
25
|
+
file: { name: "3wi2oh", styles: "--iconColor-accessory-05fc46:var(--cnvs-sys-color-fg-default);--tileBackground-accessory-05fc46:var(--cnvs-sys-color-surface-alt-default, var(--cnvs-sys-color-bg-alt-soft, oklch(0.3343 0.0951 253.3 / 0.05)));" },
|
|
26
|
+
txt: { name: "xtqa7", styles: "--iconColor-accessory-05fc46:var(--cnvs-sys-color-fg-default);--tileBackground-accessory-05fc46:var(--cnvs-sys-color-surface-alt-default, var(--cnvs-sys-color-bg-alt-soft, oklch(0.3343 0.0951 253.3 / 0.05)));" }
|
|
27
|
+
},
|
|
28
|
+
outline: {
|
|
29
|
+
true: { name: "28bkv3", styles: "[data-part=\"accessory-icon\"]{border-width:0.0625rem;border-style:solid;border-color:var(--cnvs-sys-color-border-default, var(--cnvs-sys-color-border-divider, oklch(0.3057 0.079 256.22 / 0.13)));}" }
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
defaultModifiers: {
|
|
33
|
+
type: 'file',
|
|
34
|
+
}
|
|
35
|
+
}, "accessory-file-3a7be4");
|
|
36
|
+
const fileIcons = {
|
|
37
|
+
pdf: pdfIcon,
|
|
38
|
+
spreadsheet: tableExpandIcon,
|
|
39
|
+
document: documentIcon,
|
|
40
|
+
presentation: stackIcon,
|
|
41
|
+
video: playCircleIcon,
|
|
42
|
+
file: documentIcon,
|
|
43
|
+
txt: txtIcon,
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* `AccessoryFile` renders a file-type tile. `type` chooses the glyph and sets the fill and icon
|
|
47
|
+
* color. Colored types keep their fill at every size. Generic file and text use `surface.alt` and
|
|
48
|
+
* a `border.default` stroke. Always decorative.
|
|
49
|
+
*/
|
|
50
|
+
export const AccessoryFile = createComponent('span')({
|
|
51
|
+
displayName: 'AccessoryFile',
|
|
52
|
+
Component: ({ type = 'file', size = 'extraLarge', color, background, ...elemProps }, ref, Element) => {
|
|
53
|
+
return (_jsx(Accessory, { as: Element, ref: ref, background: background, color: color, size: size, ...handleCsProp(elemProps, accessoryFileStencil({ type, outline: type === 'file' || type === 'txt' })), children: _jsx(SystemIcon, { icon: fileIcons[type], ...accessoryStencil.parts.icon }) }));
|
|
54
|
+
},
|
|
55
|
+
});
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { SystemIconProps } from '@workday/canvas-kit-react/icon';
|
|
2
|
+
import { AccessoryProps } from './Accessory';
|
|
3
|
+
/**
|
|
4
|
+
* The color treatment of `AccessoryIcon`.
|
|
5
|
+
*/
|
|
6
|
+
export type AccessoryIconVariant = 'grey' | 'green' | 'blue' | 'purple' | 'amber' | 'magenta' | 'red' | 'orange' | 'outline';
|
|
7
|
+
export interface AccessoryIconProps extends AccessoryProps {
|
|
8
|
+
/**
|
|
9
|
+
* The icon to display from `@workday/canvas-system-icons-web`.
|
|
10
|
+
*/
|
|
11
|
+
icon: SystemIconProps['icon'];
|
|
12
|
+
/**
|
|
13
|
+
* The color treatment of the icon and, at `medium` and above, the tile fill. `color` and
|
|
14
|
+
* `background` from `Accessory` override these. Variant fills stay hidden at `small` and
|
|
15
|
+
* `extraSmall` unless `background` is set.
|
|
16
|
+
* @default 'grey'
|
|
17
|
+
*/
|
|
18
|
+
variant?: AccessoryIconVariant;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Color treatment for `AccessoryIcon`. `variant` paints the icon part. `extraSmall` and `small`
|
|
22
|
+
* clear that fill and border unless `background` sets the tile variable. `color` and `background`
|
|
23
|
+
* on `Accessory` still override the variant.
|
|
24
|
+
*/
|
|
25
|
+
export declare const accessoryIconStencil: import("@workday/canvas-kit-styling").Stencil<{
|
|
26
|
+
variant: {
|
|
27
|
+
grey: ({ iconPart }: {} & import("@workday/canvas-kit-styling").StencilVarsParts<{
|
|
28
|
+
readonly icon: "accessory-icon";
|
|
29
|
+
}>) => {
|
|
30
|
+
"[data-part=\"accessory-icon\"]": {
|
|
31
|
+
[x: string]: `var(--${string}, var(--cnvs-sys-color-surface-alt-strong, var(--cnvs-sys-color-bg-alt-default, oklch(0.3337 0.0688 250.79 / 0.09))))` | `var(--${string}, var(--cnvs-base-palette-slate-800, oklch(0.3685 0.0218 256.4 / 1)))`;
|
|
32
|
+
backgroundColor: `var(--${string}, var(--cnvs-sys-color-surface-alt-strong, var(--cnvs-sys-color-bg-alt-default, oklch(0.3337 0.0688 250.79 / 0.09))))`;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
green: ({ iconPart }: {} & import("@workday/canvas-kit-styling").StencilVarsParts<{
|
|
36
|
+
readonly icon: "accessory-icon";
|
|
37
|
+
}>) => {
|
|
38
|
+
"[data-part=\"accessory-icon\"]": {
|
|
39
|
+
[x: string]: `var(--${string}, var(--cnvs-sys-color-surface-success-strong, oklch(0.8685 0.2814 143.77 / 0.15)))` | `var(--${string}, var(--cnvs-base-palette-green-800, oklch(0.3955 0.1156 147.66 / 1)))`;
|
|
40
|
+
backgroundColor: `var(--${string}, var(--cnvs-sys-color-surface-success-strong, oklch(0.8685 0.2814 143.77 / 0.15)))`;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
blue: ({ iconPart }: {} & import("@workday/canvas-kit-styling").StencilVarsParts<{
|
|
44
|
+
readonly icon: "accessory-icon";
|
|
45
|
+
}>) => {
|
|
46
|
+
"[data-part=\"accessory-icon\"]": {
|
|
47
|
+
[x: string]: `var(--${string}, var(--cnvs-sys-color-surface-info-strong, var(--cnvs-sys-color-bg-info-softer, oklch(0.6152 0.2108 256.1 / 0.11))))` | `var(--${string}, var(--cnvs-sys-color-fg-info-strong, var(--cnvs-sys-color-fg-primary-strong, oklch(0.4658 0.1562 255.5 / 1))))`;
|
|
48
|
+
backgroundColor: `var(--${string}, var(--cnvs-sys-color-surface-info-strong, var(--cnvs-sys-color-bg-info-softer, oklch(0.6152 0.2108 256.1 / 0.11))))`;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
purple: ({ iconPart }: {} & import("@workday/canvas-kit-styling").StencilVarsParts<{
|
|
52
|
+
readonly icon: "accessory-icon";
|
|
53
|
+
}>) => {
|
|
54
|
+
"[data-part=\"accessory-icon\"]": {
|
|
55
|
+
[x: string]: `var(--${string}, var(--cnvs-base-palette-purple-a50, oklch(0.5645 0.2935 302.36 / 0.09)))` | `var(--${string}, var(--cnvs-base-palette-purple-700, oklch(0.476 0.156 313.2 / 1)))`;
|
|
56
|
+
backgroundColor: `var(--${string}, var(--cnvs-base-palette-purple-a50, oklch(0.5645 0.2935 302.36 / 0.09)))`;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
amber: ({ iconPart }: {} & import("@workday/canvas-kit-styling").StencilVarsParts<{
|
|
60
|
+
readonly icon: "accessory-icon";
|
|
61
|
+
}>) => {
|
|
62
|
+
"[data-part=\"accessory-icon\"]": {
|
|
63
|
+
[x: string]: `var(--${string}, var(--cnvs-sys-color-surface-warning-strong, var(--cnvs-sys-color-static-amber-stronger, oklch(0.8864 0.1845 100.28 / 0.22))))` | `var(--${string}, var(--cnvs-sys-color-fg-warning-strong, oklch(0.4824 0.1353 46.11 / 1)))`;
|
|
64
|
+
backgroundColor: `var(--${string}, var(--cnvs-sys-color-surface-warning-strong, var(--cnvs-sys-color-static-amber-stronger, oklch(0.8864 0.1845 100.28 / 0.22))))`;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
magenta: ({ iconPart }: {} & import("@workday/canvas-kit-styling").StencilVarsParts<{
|
|
68
|
+
readonly icon: "accessory-icon";
|
|
69
|
+
}>) => {
|
|
70
|
+
"[data-part=\"accessory-icon\"]": {
|
|
71
|
+
[x: string]: `var(--${string}, var(--cnvs-base-palette-magenta-a50, oklch(0.7044 0.3188 328.33 / 0.08)))` | `var(--${string}, var(--cnvs-base-palette-magenta-800, oklch(0.4011 0.1269 344.4 / 1)))`;
|
|
72
|
+
backgroundColor: `var(--${string}, var(--cnvs-base-palette-magenta-a50, oklch(0.7044 0.3188 328.33 / 0.08)))`;
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
red: ({ iconPart }: {} & import("@workday/canvas-kit-styling").StencilVarsParts<{
|
|
76
|
+
readonly icon: "accessory-icon";
|
|
77
|
+
}>) => {
|
|
78
|
+
"[data-part=\"accessory-icon\"]": {
|
|
79
|
+
[x: string]: `var(--${string}, var(--cnvs-sys-color-surface-danger-strong, oklch(0.6434 0.2428 30.17 / 0.1)))` | `var(--${string}, var(--cnvs-sys-color-fg-danger-strong, var(--cnvs-sys-color-fg-critical-strong, oklch(0.4517 0.1847 28.2 / 1))))`;
|
|
80
|
+
backgroundColor: `var(--${string}, var(--cnvs-sys-color-surface-danger-strong, oklch(0.6434 0.2428 30.17 / 0.1)))`;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
orange: ({ iconPart }: {} & import("@workday/canvas-kit-styling").StencilVarsParts<{
|
|
84
|
+
readonly icon: "accessory-icon";
|
|
85
|
+
}>) => {
|
|
86
|
+
"[data-part=\"accessory-icon\"]": {
|
|
87
|
+
[x: string]: `var(--${string}, var(--cnvs-base-palette-orange-a50, oklch(0.7555 0.1769 59.35 / 0.17)))` | `var(--${string}, var(--cnvs-base-palette-orange-700, oklch(0.4689 0.1456 40.5 / 1)))`;
|
|
88
|
+
backgroundColor: `var(--${string}, var(--cnvs-base-palette-orange-a50, oklch(0.7555 0.1769 59.35 / 0.17)))`;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
outline: ({ iconPart }: {} & import("@workday/canvas-kit-styling").StencilVarsParts<{
|
|
92
|
+
readonly icon: "accessory-icon";
|
|
93
|
+
}>) => {
|
|
94
|
+
"[data-part=\"accessory-icon\"]": {
|
|
95
|
+
[x: string]: string;
|
|
96
|
+
backgroundColor: `var(--${string}, var(--cnvs-sys-color-surface-transparent, var(--cnvs-sys-color-bg-transparent-default, oklch(0 0 0 / 0))))`;
|
|
97
|
+
borderWidth: string;
|
|
98
|
+
borderStyle: string;
|
|
99
|
+
borderColor: "var(--cnvs-sys-color-border-default, var(--cnvs-sys-color-border-divider, oklch(0.3057 0.079 256.22 / 0.13)))";
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
size: {
|
|
104
|
+
extraSmall: {};
|
|
105
|
+
small: {};
|
|
106
|
+
medium: {};
|
|
107
|
+
large: {};
|
|
108
|
+
extraLarge: {};
|
|
109
|
+
};
|
|
110
|
+
}, {
|
|
111
|
+
readonly icon: "accessory-icon";
|
|
112
|
+
}, Record<string, string> | Record<string, Record<string, string>>, never, never>;
|
|
113
|
+
/**
|
|
114
|
+
* `AccessoryIcon` renders a system icon in an accessory tile. `variant` sets the tile fill and
|
|
115
|
+
* icon color. `color` and `background` on the shared `Accessory` props override the variant. The
|
|
116
|
+
* glyph size comes from `size` on `Accessory` through the icon `data-part`. Always decorative.
|
|
117
|
+
*/
|
|
118
|
+
export declare const AccessoryIcon: import("@workday/canvas-kit-react/common").ElementComponent<"span", AccessoryIconProps>;
|
|
119
|
+
//# sourceMappingURL=AccessoryIcon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccessoryIcon.d.ts","sourceRoot":"","sources":["../../../../accessory/lib/AccessoryIcon.tsx"],"names":[],"mappings":"AACA,OAAO,EAAa,eAAe,EAAoB,MAAM,gCAAgC,CAAC;AAI9F,OAAO,EAAY,cAAc,EAAmB,MAAM,aAAa,CAAC;AAExE;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAC5B,MAAM,GACN,OAAO,GACP,MAAM,GACN,QAAQ,GACR,OAAO,GACP,SAAS,GACT,KAAK,GACL,QAAQ,GACR,SAAS,CAAC;AAEd,MAAM,WAAW,kBAAmB,SAAQ,cAAc;IACxD;;OAEG;IACH,IAAI,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC;IAC9B;;;;;OAKG;IACH,OAAO,CAAC,EAAE,oBAAoB,CAAC;CAChC;AAED;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iFA0I/B,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,aAAa,yFA2BxB,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createComponent } from '@workday/canvas-kit-react/common';
|
|
3
|
+
import { SystemIcon, systemIconStencil } from '@workday/canvas-kit-react/icon';
|
|
4
|
+
import { createStencil, cssVar, handleCsProp, px2rem } from '@workday/canvas-kit-styling';
|
|
5
|
+
import { base, system } from '@workday/canvas-tokens-web';
|
|
6
|
+
import { Accessory, accessoryStencil } from './Accessory';
|
|
7
|
+
/**
|
|
8
|
+
* Color treatment for `AccessoryIcon`. `variant` paints the icon part. `extraSmall` and `small`
|
|
9
|
+
* clear that fill and border unless `background` sets the tile variable. `color` and `background`
|
|
10
|
+
* on `Accessory` still override the variant.
|
|
11
|
+
*/
|
|
12
|
+
export const accessoryIconStencil = createStencil({
|
|
13
|
+
parts: {
|
|
14
|
+
icon: 'accessory-icon',
|
|
15
|
+
},
|
|
16
|
+
base: { name: "27ky9e", styles: "box-sizing:border-box;" },
|
|
17
|
+
modifiers: {
|
|
18
|
+
variant: {
|
|
19
|
+
grey: { name: "1ndba8", styles: "[data-part=\"accessory-icon\"]{background-color:var(--tileBackground-accessory-05fc46, var(--cnvs-sys-color-surface-alt-strong, var(--cnvs-sys-color-bg-alt-default, oklch(0.3337 0.0688 250.79 / 0.09))));--color-system-icon-c9acc3:var(--iconColor-accessory-05fc46, var(--cnvs-base-palette-slate-800, oklch(0.3685 0.0218 256.4 / 1)));}" },
|
|
20
|
+
green: { name: "3bbrxz", styles: "[data-part=\"accessory-icon\"]{background-color:var(--tileBackground-accessory-05fc46, var(--cnvs-sys-color-surface-success-strong, oklch(0.8685 0.2814 143.77 / 0.15)));--color-system-icon-c9acc3:var(--iconColor-accessory-05fc46, var(--cnvs-base-palette-green-800, oklch(0.3955 0.1156 147.66 / 1)));}" },
|
|
21
|
+
blue: { name: "4csff1", styles: "[data-part=\"accessory-icon\"]{background-color:var(--tileBackground-accessory-05fc46, var(--cnvs-sys-color-surface-info-strong, var(--cnvs-sys-color-bg-info-softer, oklch(0.6152 0.2108 256.1 / 0.11))));--color-system-icon-c9acc3:var(--iconColor-accessory-05fc46, var(--cnvs-sys-color-fg-info-strong, var(--cnvs-sys-color-fg-primary-strong, oklch(0.4658 0.1562 255.5 / 1))));}" },
|
|
22
|
+
purple: { name: "1t854z", styles: "[data-part=\"accessory-icon\"]{background-color:var(--tileBackground-accessory-05fc46, var(--cnvs-base-palette-purple-a50, oklch(0.5645 0.2935 302.36 / 0.09)));--color-system-icon-c9acc3:var(--iconColor-accessory-05fc46, var(--cnvs-base-palette-purple-700, oklch(0.476 0.156 313.2 / 1)));}" },
|
|
23
|
+
amber: { name: "27f6v1", styles: "[data-part=\"accessory-icon\"]{background-color:var(--tileBackground-accessory-05fc46, var(--cnvs-sys-color-surface-warning-strong, var(--cnvs-sys-color-static-amber-stronger, oklch(0.8864 0.1845 100.28 / 0.22))));--color-system-icon-c9acc3:var(--iconColor-accessory-05fc46, var(--cnvs-sys-color-fg-warning-strong, oklch(0.4824 0.1353 46.11 / 1)));}" },
|
|
24
|
+
magenta: { name: "4cuggm", styles: "[data-part=\"accessory-icon\"]{background-color:var(--tileBackground-accessory-05fc46, var(--cnvs-base-palette-magenta-a50, oklch(0.7044 0.3188 328.33 / 0.08)));--color-system-icon-c9acc3:var(--iconColor-accessory-05fc46, var(--cnvs-base-palette-magenta-800, oklch(0.4011 0.1269 344.4 / 1)));}" },
|
|
25
|
+
red: { name: "1n558n", styles: "[data-part=\"accessory-icon\"]{background-color:var(--tileBackground-accessory-05fc46, var(--cnvs-sys-color-surface-danger-strong, oklch(0.6434 0.2428 30.17 / 0.1)));--color-system-icon-c9acc3:var(--iconColor-accessory-05fc46, var(--cnvs-sys-color-fg-danger-strong, var(--cnvs-sys-color-fg-critical-strong, oklch(0.4517 0.1847 28.2 / 1))));}" },
|
|
26
|
+
orange: { name: "1g4u9r", styles: "[data-part=\"accessory-icon\"]{background-color:var(--tileBackground-accessory-05fc46, var(--cnvs-base-palette-orange-a50, oklch(0.7555 0.1769 59.35 / 0.17)));--color-system-icon-c9acc3:var(--iconColor-accessory-05fc46, var(--cnvs-base-palette-orange-700, oklch(0.4689 0.1456 40.5 / 1)));}" },
|
|
27
|
+
outline: { name: "leqho", styles: "[data-part=\"accessory-icon\"]{background-color:var(--tileBackground-accessory-05fc46, var(--cnvs-sys-color-surface-transparent, var(--cnvs-sys-color-bg-transparent-default, oklch(0 0 0 / 0))));--color-system-icon-c9acc3:var(--iconColor-accessory-05fc46, var(--cnvs-base-palette-slate-800, oklch(0.3685 0.0218 256.4 / 1)));border-width:0.0625rem;border-style:solid;border-color:var(--cnvs-sys-color-border-default, var(--cnvs-sys-color-border-divider, oklch(0.3057 0.079 256.22 / 0.13)));}" }
|
|
28
|
+
},
|
|
29
|
+
size: {
|
|
30
|
+
extraSmall: { name: "48b1cs", styles: "" },
|
|
31
|
+
small: { name: "sahhq", styles: "" },
|
|
32
|
+
medium: { name: "39yqre", styles: "" },
|
|
33
|
+
large: { name: "1e0oxf", styles: "" },
|
|
34
|
+
extraLarge: { name: "18nuts", styles: "" }
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
compound: [
|
|
38
|
+
{
|
|
39
|
+
modifiers: { size: 'extraSmall' },
|
|
40
|
+
styles: { name: "1g820g", styles: "[data-part=\"accessory-icon\"]{background-color:var(--tileBackground-accessory-05fc46, transparent);border-width:0;}" }
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
modifiers: { size: 'small' },
|
|
44
|
+
styles: { name: "379rxz", styles: "[data-part=\"accessory-icon\"]{background-color:var(--tileBackground-accessory-05fc46, transparent);border-width:0;}" }
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
}, "accessory-icon-b2d5b9");
|
|
48
|
+
/**
|
|
49
|
+
* `AccessoryIcon` renders a system icon in an accessory tile. `variant` sets the tile fill and
|
|
50
|
+
* icon color. `color` and `background` on the shared `Accessory` props override the variant. The
|
|
51
|
+
* glyph size comes from `size` on `Accessory` through the icon `data-part`. Always decorative.
|
|
52
|
+
*/
|
|
53
|
+
export const AccessoryIcon = createComponent('span')({
|
|
54
|
+
displayName: 'AccessoryIcon',
|
|
55
|
+
Component: ({ icon, size = 'extraLarge', variant = 'grey', color, background, ...elemProps }, ref, Element) => {
|
|
56
|
+
return (_jsx(Accessory, { as: Element, ref: ref, background: background, color: color, size: size, ...handleCsProp(elemProps, accessoryIconStencil({ size, variant })), children: _jsx(SystemIcon, { icon: icon, ...accessoryStencil.parts.icon }) }));
|
|
57
|
+
},
|
|
58
|
+
});
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { SystemIconProps } from '@workday/canvas-kit-react/icon';
|
|
2
|
+
import { AccessoryProps } from './Accessory';
|
|
3
|
+
export interface AccessoryMediaProps extends AccessoryProps {
|
|
4
|
+
/**
|
|
5
|
+
* The URL of the image.
|
|
6
|
+
*/
|
|
7
|
+
src: string;
|
|
8
|
+
/**
|
|
9
|
+
* How the image is resized to fit the tile.
|
|
10
|
+
* @default 'cover'
|
|
11
|
+
*/
|
|
12
|
+
objectFit?: 'contain' | 'cover';
|
|
13
|
+
/**
|
|
14
|
+
* The icon to display from `@workday/canvas-system-icons-web`, centered over the image. When
|
|
15
|
+
* set, a scrim is painted under the icon for contrast. Uses `color` from `Accessory` for the
|
|
16
|
+
* glyph (`base.legacy.neutral0` by default).
|
|
17
|
+
*/
|
|
18
|
+
icon?: SystemIconProps['icon'];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Image treatment for `AccessoryMedia`. The image part stays hidden until `imageLoaded`. The scrim
|
|
22
|
+
* part sits under an optional icon. `background` overrides the tile fill.
|
|
23
|
+
*/
|
|
24
|
+
export declare const accessoryMediaStencil: import("@workday/canvas-kit-styling").Stencil<{
|
|
25
|
+
imageLoaded: {
|
|
26
|
+
false: ({ imagePart }: {
|
|
27
|
+
background: `--${string}`;
|
|
28
|
+
} & import("@workday/canvas-kit-styling").StencilVarsParts<{
|
|
29
|
+
readonly image: "accessory-media-image";
|
|
30
|
+
readonly scrim: "accessory-media-scrim";
|
|
31
|
+
}>) => {
|
|
32
|
+
"[data-part=\"accessory-media-image\"]": {
|
|
33
|
+
display: string;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
true: {};
|
|
37
|
+
};
|
|
38
|
+
objectFit: {
|
|
39
|
+
cover: ({ imagePart }: {
|
|
40
|
+
background: `--${string}`;
|
|
41
|
+
} & import("@workday/canvas-kit-styling").StencilVarsParts<{
|
|
42
|
+
readonly image: "accessory-media-image";
|
|
43
|
+
readonly scrim: "accessory-media-scrim";
|
|
44
|
+
}>) => {
|
|
45
|
+
"[data-part=\"accessory-media-image\"]": {
|
|
46
|
+
objectFit: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
contain: ({ imagePart }: {
|
|
50
|
+
background: `--${string}`;
|
|
51
|
+
} & import("@workday/canvas-kit-styling").StencilVarsParts<{
|
|
52
|
+
readonly image: "accessory-media-image";
|
|
53
|
+
readonly scrim: "accessory-media-scrim";
|
|
54
|
+
}>) => {
|
|
55
|
+
"[data-part=\"accessory-media-image\"]": {
|
|
56
|
+
objectFit: string;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
}, {
|
|
61
|
+
readonly image: "accessory-media-image";
|
|
62
|
+
readonly scrim: "accessory-media-scrim";
|
|
63
|
+
}, {
|
|
64
|
+
background: string;
|
|
65
|
+
}, never, never>;
|
|
66
|
+
/**
|
|
67
|
+
* `AccessoryMedia` fills an accessory tile with an image. Pass `icon` to center a decorative icon
|
|
68
|
+
* on a contrast scrim. The image stays hidden until it loads; a failed load keeps the tile
|
|
69
|
+
* background. Always decorative.
|
|
70
|
+
*/
|
|
71
|
+
export declare const AccessoryMedia: import("@workday/canvas-kit-react/common").ElementComponent<"span", AccessoryMediaProps>;
|
|
72
|
+
//# sourceMappingURL=AccessoryMedia.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccessoryMedia.d.ts","sourceRoot":"","sources":["../../../../accessory/lib/AccessoryMedia.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAa,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAI3E,OAAO,EAAY,cAAc,EAAmB,MAAM,aAAa,CAAC;AAExE,MAAM,WAAW,mBAAoB,SAAQ,cAAc;IACzD;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;;OAGG;IACH,SAAS,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC;IAChC;;;;OAIG;IACH,IAAI,CAAC,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC;CAChC;AAED;;;GAGG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAmDhC,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,cAAc,0FAoDzB,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { cornerShapeStencil, createComponent } from '@workday/canvas-kit-react/common';
|
|
4
|
+
import { SystemIcon } from '@workday/canvas-kit-react/icon';
|
|
5
|
+
import { createStencil, cssVar, handleCsProp } from '@workday/canvas-kit-styling';
|
|
6
|
+
import { base, system } from '@workday/canvas-tokens-web';
|
|
7
|
+
import { Accessory, accessoryStencil } from './Accessory';
|
|
8
|
+
/**
|
|
9
|
+
* Image treatment for `AccessoryMedia`. The image part stays hidden until `imageLoaded`. The scrim
|
|
10
|
+
* part sits under an optional icon. `background` overrides the tile fill.
|
|
11
|
+
*/
|
|
12
|
+
export const accessoryMediaStencil = createStencil({
|
|
13
|
+
vars: {
|
|
14
|
+
background: '',
|
|
15
|
+
},
|
|
16
|
+
parts: {
|
|
17
|
+
image: 'accessory-media-image',
|
|
18
|
+
scrim: 'accessory-media-scrim',
|
|
19
|
+
},
|
|
20
|
+
base: { name: "3wew7z", styles: "box-sizing:border-box;background-color:var(--background-accessory-media-9cf347, var(--cnvs-sys-color-surface-alt-default, var(--cnvs-sys-color-bg-alt-soft, oklch(0.3343 0.0951 253.3 / 0.05))));[data-part=\"accessory-media-image\"]{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;overflow:hidden;border-radius:var(--shape-corner-shape-ccab68);corner-shape:superellipse(1.1);}[data-part=\"accessory-media-scrim\"]{position:absolute;inset:0;background-color:var(--cnvs-sys-color-surface-overlay-scrim, oklch(0.0847 0 0 / 0.36));border-radius:var(--shape-corner-shape-ccab68);corner-shape:superellipse(1.1);pointer-events:none;}" },
|
|
21
|
+
modifiers: {
|
|
22
|
+
imageLoaded: {
|
|
23
|
+
false: { name: "ruy4j", styles: "[data-part=\"accessory-media-image\"]{display:none;}" },
|
|
24
|
+
true: { name: "2yeyuo", styles: "" }
|
|
25
|
+
},
|
|
26
|
+
objectFit: {
|
|
27
|
+
cover: { name: "2tjew2", styles: "[data-part=\"accessory-media-image\"]{object-fit:cover;}" },
|
|
28
|
+
contain: { name: "1hjptw", styles: "[data-part=\"accessory-media-image\"]{object-fit:contain;}" }
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}, "accessory-media-9cf347");
|
|
32
|
+
/**
|
|
33
|
+
* `AccessoryMedia` fills an accessory tile with an image. Pass `icon` to center a decorative icon
|
|
34
|
+
* on a contrast scrim. The image stays hidden until it loads; a failed load keeps the tile
|
|
35
|
+
* background. Always decorative.
|
|
36
|
+
*/
|
|
37
|
+
export const AccessoryMedia = createComponent('span')({
|
|
38
|
+
displayName: 'AccessoryMedia',
|
|
39
|
+
Component: ({ src, size = 'extraLarge', objectFit = 'cover', icon, color = base.legacy.neutral0, background, ...elemProps }, ref, Element) => {
|
|
40
|
+
// Track the loaded URL so a `src` change hides the image again without a mount effect that
|
|
41
|
+
// can race a synchronous `onLoad` (cached images and data URLs).
|
|
42
|
+
const [loadedSrc, setLoadedSrc] = React.useState(null);
|
|
43
|
+
const imageRef = React.useRef(null);
|
|
44
|
+
const imageLoaded = loadedSrc === src;
|
|
45
|
+
React.useEffect(() => {
|
|
46
|
+
const image = imageRef.current;
|
|
47
|
+
if ((image === null || image === void 0 ? void 0 : image.complete) && image.naturalWidth > 0) {
|
|
48
|
+
setLoadedSrc(src);
|
|
49
|
+
}
|
|
50
|
+
}, [src]);
|
|
51
|
+
return (_jsxs(Accessory, { as: Element, ref: ref, color: icon ? color : undefined, size: size, ...handleCsProp(elemProps, accessoryMediaStencil({ background, imageLoaded, objectFit })), children: [_jsx("img", { ref: imageRef, alt: "", onLoad: () => setLoadedSrc(src), src: src, ...accessoryMediaStencil.parts.image }), icon && (_jsxs(_Fragment, { children: [_jsx("span", { ...accessoryMediaStencil.parts.scrim }), _jsx(SystemIcon, { icon: icon, ...accessoryStencil.parts.icon })] }))] }));
|
|
52
|
+
},
|
|
53
|
+
});
|
package/dist/es6/index.d.ts
CHANGED
package/dist/es6/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,OAAO,CAAC;AACtB,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,OAAO,CAAC;AACtB,cAAc,mBAAmB,CAAC;AAClC,cAAc,WAAW,CAAC"}
|
package/dist/es6/index.js
CHANGED
package/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workday/canvas-kit-labs-react",
|
|
3
|
-
"version": "16.2.0-
|
|
3
|
+
"version": "16.2.0-0654-next.0",
|
|
4
4
|
"description": "Canvas Kit Labs is an incubator for new and experimental components. Since we have a rather rigorous process for getting components in at a production level, it can be valuable to make them available earlier while we continuously iterate on the API/functionality. The Labs modules allow us to do that as needed.",
|
|
5
5
|
"author": "Workday, Inc. (https://www.workday.com)",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@emotion/react": "^11.7.1",
|
|
50
50
|
"@emotion/styled": "^11.6.0",
|
|
51
|
-
"@workday/canvas-kit-react": "^16.2.0-
|
|
52
|
-
"@workday/canvas-kit-styling": "^16.2.0-
|
|
51
|
+
"@workday/canvas-kit-react": "^16.2.0-0654-next.0",
|
|
52
|
+
"@workday/canvas-kit-styling": "^16.2.0-0654-next.0",
|
|
53
53
|
"@workday/canvas-system-icons-web": "^5.0.3",
|
|
54
54
|
"@workday/canvas-tokens-web": "^4.4.0",
|
|
55
55
|
"@workday/design-assets-types": "^0.3.0",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@types/lodash.flatten": "^4.4.6"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "e022131cf84954c1a0dc8b47b4c32dd0bebb07ff"
|
|
64
64
|
}
|