@lumx/core 4.0.1-alpha.2 → 4.0.1-alpha.4
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/_internal/2_dvYIIO.js +41 -0
- package/_internal/CWVyFRGV.js +27 -0
- package/js/components/Icon/index.d.ts +36 -0
- package/js/components/Icon/index.js +71 -0
- package/js/utils/classNames/spacing/index.js +2 -2
- package/lumx.css +0 -14
- package/package.json +3 -1
- package/scss/components/slideshow/_index.scss +1 -16
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import classNames from 'classnames';
|
|
2
|
+
import isBoolean from 'lodash/isBoolean';
|
|
3
|
+
import isEmpty from 'lodash/isEmpty';
|
|
4
|
+
import { getBasicClass } from './CWVyFRGV.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Enhance isEmpty method to also works with numbers.
|
|
8
|
+
*
|
|
9
|
+
* @param value The value to check.
|
|
10
|
+
* @return Whether the input value is empty or != 0.
|
|
11
|
+
*/
|
|
12
|
+
const _isEmpty = (value) => {
|
|
13
|
+
if (typeof value === 'number') {
|
|
14
|
+
return value === 0;
|
|
15
|
+
}
|
|
16
|
+
return isEmpty(value);
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Return all basic LumX CSS classes which are available for every components.
|
|
20
|
+
*
|
|
21
|
+
* @see {@link /src/components/index.d.ts} for the possible values of each parameter.
|
|
22
|
+
*
|
|
23
|
+
* @param prefix The class name prefix for the generated CSS class.
|
|
24
|
+
* @param props All the other props you want to generate a class.
|
|
25
|
+
* The rule of thumb: the key is the name of the prop in the class, the value a string that will
|
|
26
|
+
* be used in the classname to represent the value of the given prop.
|
|
27
|
+
* @return All LumX basic CSS classes.
|
|
28
|
+
*/
|
|
29
|
+
function handleBasicClasses({ prefix, ...props }) {
|
|
30
|
+
const otherClasses = {};
|
|
31
|
+
if (!isEmpty(props)) {
|
|
32
|
+
Object.keys(props).forEach((prop) => {
|
|
33
|
+
otherClasses[getBasicClass({ prefix, type: prop, value: props[prop] })] = isBoolean(props[prop])
|
|
34
|
+
? props[prop]
|
|
35
|
+
: !_isEmpty(props[prop]);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return classNames(prefix, otherClasses);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export { handleBasicClasses };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import isBoolean from 'lodash/isBoolean';
|
|
2
|
+
import kebabCase from 'lodash/kebabCase';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Get the basic CSS class for the given type.
|
|
6
|
+
*
|
|
7
|
+
* @param prefix The class name prefix for the generated CSS class.
|
|
8
|
+
* @param type The type of CSS class we want to generate (e.g.: 'color', 'variant', ...).
|
|
9
|
+
* @param value The value of the type of the CSS class (e.g.: 'primary', 'button', ...).
|
|
10
|
+
* @return The basic CSS class.
|
|
11
|
+
*/
|
|
12
|
+
function getBasicClass({ prefix, type, value, }) {
|
|
13
|
+
if (isBoolean(value)) {
|
|
14
|
+
if (!value) {
|
|
15
|
+
// False value should not return a class.
|
|
16
|
+
return '';
|
|
17
|
+
}
|
|
18
|
+
const booleanPrefixes = ['has', 'is'];
|
|
19
|
+
if (booleanPrefixes.some((booleanPrefix) => type.toString().startsWith(booleanPrefix))) {
|
|
20
|
+
return `${prefix}--${kebabCase(type)}`;
|
|
21
|
+
}
|
|
22
|
+
return `${prefix}--is-${kebabCase(type)}`;
|
|
23
|
+
}
|
|
24
|
+
return `${prefix}--${kebabCase(type)}-${value}`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { getBasicClass };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { GenericProps, HasTheme } from '../../types';
|
|
2
|
+
import { ColorVariant, ColorWithVariants, Size } from '../../constants';
|
|
3
|
+
export type IconSizes = Extract<Size, 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl'>;
|
|
4
|
+
/**
|
|
5
|
+
* Defines the props of the component.
|
|
6
|
+
*/
|
|
7
|
+
export interface IconProps extends GenericProps, HasTheme {
|
|
8
|
+
/** Color variant. */
|
|
9
|
+
color?: ColorWithVariants;
|
|
10
|
+
/** Lightened or darkened variant of the selected icon color. */
|
|
11
|
+
colorVariant?: ColorVariant;
|
|
12
|
+
/** Whether the icon has a shape. */
|
|
13
|
+
hasShape?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Icon (SVG path) draw code (`d` property of the `<path>` SVG element).
|
|
16
|
+
* See https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths
|
|
17
|
+
*/
|
|
18
|
+
icon: string;
|
|
19
|
+
/** Size variant. */
|
|
20
|
+
size?: IconSizes;
|
|
21
|
+
/** Sets an alternative text on the svg. Will set an `img` role to the svg. */
|
|
22
|
+
alt?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Icon component.
|
|
26
|
+
*
|
|
27
|
+
* @param props Component props.
|
|
28
|
+
* @param ref Component ref.
|
|
29
|
+
* @return React element.
|
|
30
|
+
*/
|
|
31
|
+
export declare const Icon: {
|
|
32
|
+
(props: IconProps): JSX.Element;
|
|
33
|
+
displayName: string;
|
|
34
|
+
className: "lumx-icon";
|
|
35
|
+
defaultProps: Partial<IconProps>;
|
|
36
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { mdiAlertCircle } from '@lumx/icons';
|
|
3
|
+
import { handleBasicClasses } from '../../../_internal/2_dvYIIO.js';
|
|
4
|
+
import 'lodash/isBoolean';
|
|
5
|
+
import 'lodash/kebabCase';
|
|
6
|
+
import { resolveColorWithVariants } from '../../../_internal/DPnPEC08.js';
|
|
7
|
+
import classNames from 'classnames';
|
|
8
|
+
import { ColorPalette, Theme, Size } from '../../constants/enums/index.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Component display name.
|
|
12
|
+
*/
|
|
13
|
+
const COMPONENT_NAME = 'Icon';
|
|
14
|
+
/**
|
|
15
|
+
* Component default class name and class prefix.
|
|
16
|
+
*/
|
|
17
|
+
const CLASSNAME = 'lumx-icon';
|
|
18
|
+
/**
|
|
19
|
+
* Component default props.
|
|
20
|
+
*/
|
|
21
|
+
const DEFAULT_PROPS = {};
|
|
22
|
+
/**
|
|
23
|
+
* Icon component.
|
|
24
|
+
*
|
|
25
|
+
* @param props Component props.
|
|
26
|
+
* @param ref Component ref.
|
|
27
|
+
* @return React element.
|
|
28
|
+
*/
|
|
29
|
+
const Icon = (props) => {
|
|
30
|
+
const { className, color: propColor, colorVariant: propColorVariant, hasShape, icon, size, ref, theme, alt, ...forwardedProps } = props;
|
|
31
|
+
const [color, colorVariant] = resolveColorWithVariants(propColor, propColorVariant);
|
|
32
|
+
// Color
|
|
33
|
+
let iconColor = color;
|
|
34
|
+
if (!iconColor && (hasShape || theme)) {
|
|
35
|
+
iconColor = theme === Theme.dark ? ColorPalette.light : ColorPalette.dark;
|
|
36
|
+
}
|
|
37
|
+
// Color variant
|
|
38
|
+
let iconColorVariant = colorVariant;
|
|
39
|
+
if (!iconColorVariant && hasShape && iconColor === ColorPalette.dark) {
|
|
40
|
+
iconColorVariant = 'L2';
|
|
41
|
+
}
|
|
42
|
+
// Size
|
|
43
|
+
let iconSize = size;
|
|
44
|
+
if (size && hasShape) {
|
|
45
|
+
if (size === Size.xxs || size === Size.xs) {
|
|
46
|
+
iconSize = Size.s;
|
|
47
|
+
}
|
|
48
|
+
else if (size === Size.xxl) {
|
|
49
|
+
iconSize = Size.xl;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
else if (hasShape) {
|
|
53
|
+
iconSize = Size.m;
|
|
54
|
+
}
|
|
55
|
+
return (jsx("i", { ref: ref, ...forwardedProps, className: classNames(className, handleBasicClasses({
|
|
56
|
+
color: iconColor,
|
|
57
|
+
colorVariant: iconColorVariant,
|
|
58
|
+
hasShape,
|
|
59
|
+
prefix: CLASSNAME,
|
|
60
|
+
theme,
|
|
61
|
+
size: iconSize,
|
|
62
|
+
}), !hasShape && `${CLASSNAME}--no-shape`, !hasShape &&
|
|
63
|
+
iconColor === ColorPalette.yellow &&
|
|
64
|
+
icon === mdiAlertCircle &&
|
|
65
|
+
`${CLASSNAME}--has-dark-layer`, `${CLASSNAME}--path`), children: jsx("svg", { "aria-hidden": alt ? undefined : 'true', role: alt ? 'img' : undefined, "aria-label": alt, height: "1em", preserveAspectRatio: "xMidYMid meet", style: { verticalAlign: '-0.125em' }, viewBox: "0 0 24 24", width: "1em", children: jsx("path", { d: icon, fill: "currentColor" }) }) }));
|
|
66
|
+
};
|
|
67
|
+
Icon.displayName = COMPONENT_NAME;
|
|
68
|
+
Icon.className = CLASSNAME;
|
|
69
|
+
Icon.defaultProps = DEFAULT_PROPS;
|
|
70
|
+
|
|
71
|
+
export { Icon };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import classNames from 'classnames';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Returns a lumx classname for the given type, direction and size. For example, for
|
|
@@ -31,7 +31,7 @@ function spacing(type, direction, size) {
|
|
|
31
31
|
* @param spacingConfigs - Array of spacing configurations with direction and size
|
|
32
32
|
* @returns string
|
|
33
33
|
*/
|
|
34
|
-
const spacings = (spacingConfigs) =>
|
|
34
|
+
const spacings = (spacingConfigs) => classNames(spacingConfigs.map((spa) => spacing(spa.type, spa.direction, spa.size)));
|
|
35
35
|
/**
|
|
36
36
|
* Returns a lumx margin classname for the given direction and size. For example, for
|
|
37
37
|
* arguments direction='right', size='regular' it returns lumx-spacing-margin-right-regular
|
package/lumx.css
CHANGED
|
@@ -10883,19 +10883,6 @@ table {
|
|
|
10883
10883
|
flex: 1 1 auto;
|
|
10884
10884
|
min-height: 0;
|
|
10885
10885
|
}
|
|
10886
|
-
.lumx-slideshow__wrapper--mode-scroll-snap {
|
|
10887
|
-
overflow-x: auto;
|
|
10888
|
-
scroll-snap-type: x mandatory;
|
|
10889
|
-
scrollbar-width: none;
|
|
10890
|
-
}
|
|
10891
|
-
@media (prefers-reduced-motion: no-preference) {
|
|
10892
|
-
.lumx-slideshow__wrapper--mode-scroll-snap {
|
|
10893
|
-
scroll-behavior: smooth;
|
|
10894
|
-
}
|
|
10895
|
-
}
|
|
10896
|
-
.lumx-slideshow__wrapper--mode-scroll-snap::-webkit-scrollbar {
|
|
10897
|
-
display: none;
|
|
10898
|
-
}
|
|
10899
10886
|
.lumx-slideshow__controls {
|
|
10900
10887
|
margin-top: 16px;
|
|
10901
10888
|
}
|
|
@@ -10910,7 +10897,6 @@ table {
|
|
|
10910
10897
|
overflow: hidden;
|
|
10911
10898
|
max-width: 100%;
|
|
10912
10899
|
flex: 0 0 100%;
|
|
10913
|
-
scroll-snap-align: start;
|
|
10914
10900
|
}
|
|
10915
10901
|
|
|
10916
10902
|
/* Slideshow item
|
package/package.json
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
"url": "https://github.com/lumapps/design-system/issues"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
+
"@lumx/icons": "^4.0.1-alpha.4",
|
|
9
10
|
"classnames": "^2.3.2",
|
|
10
11
|
"focus-visible": "^5.0.2",
|
|
11
12
|
"lodash": "4.17.21",
|
|
@@ -35,7 +36,7 @@
|
|
|
35
36
|
"update-version-changelog": "yarn version-changelog ../../CHANGELOG.md"
|
|
36
37
|
},
|
|
37
38
|
"sideEffects": false,
|
|
38
|
-
"version": "4.0.1-alpha.
|
|
39
|
+
"version": "4.0.1-alpha.4",
|
|
39
40
|
"devDependencies": {
|
|
40
41
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
41
42
|
"@testing-library/dom": "^10.4.1",
|
|
@@ -46,6 +47,7 @@
|
|
|
46
47
|
"rollup": "^4.53.3",
|
|
47
48
|
"rollup-plugin-cleaner": "^1.0.0",
|
|
48
49
|
"rollup-plugin-copy": "^3.5.0",
|
|
50
|
+
"rollup-plugin-ts-paths-resolve": "^1.7.1",
|
|
49
51
|
"sass": "^1.54.0",
|
|
50
52
|
"style-dictionary": "^3.9.0",
|
|
51
53
|
"tinycolor2": "^1.4.1",
|
|
@@ -38,20 +38,6 @@
|
|
|
38
38
|
flex: 1 1 auto;
|
|
39
39
|
min-height: 0;
|
|
40
40
|
}
|
|
41
|
-
|
|
42
|
-
&--mode-scroll-snap {
|
|
43
|
-
overflow-x: auto;
|
|
44
|
-
scroll-snap-type: x mandatory;
|
|
45
|
-
scrollbar-width: none;
|
|
46
|
-
|
|
47
|
-
@media (prefers-reduced-motion: no-preference) {
|
|
48
|
-
scroll-behavior: smooth;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
&::-webkit-scrollbar {
|
|
52
|
-
display: none;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
41
|
}
|
|
56
42
|
|
|
57
43
|
&__controls {
|
|
@@ -71,7 +57,6 @@
|
|
|
71
57
|
overflow: hidden;
|
|
72
58
|
max-width: 100%;
|
|
73
59
|
flex: 0 0 100%;
|
|
74
|
-
scroll-snap-align: start;
|
|
75
60
|
}
|
|
76
61
|
|
|
77
62
|
/* Slideshow item
|
|
@@ -162,7 +147,7 @@
|
|
|
162
147
|
width: $item-size*2;
|
|
163
148
|
border-radius: $lumx-border-radius;
|
|
164
149
|
border-width: 0;
|
|
165
|
-
|
|
150
|
+
|
|
166
151
|
&[data-focus-visible-added] {
|
|
167
152
|
@include lumx-state(lumx-base-const("state", "FOCUS"), lumx-base-const("emphasis", "LOW"), "primary");
|
|
168
153
|
}
|