@lumx/react 2.2.22-alpha-fix-generic-block.2 → 2.2.23
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/esm/_internal/Link2.js.map +1 -1
- package/esm/_internal/Thumbnail2.js +26 -12
- package/esm/_internal/Thumbnail2.js.map +1 -1
- package/esm/_internal/components.js +7 -7
- package/esm/_internal/components.js.map +1 -1
- package/esm/index.js +1 -1
- package/package.json +4 -4
- package/src/components/index.ts +7 -7
- package/src/components/link/Link.stories.tsx +70 -40
- package/src/components/link/Link.tsx +2 -2
- package/src/components/thumbnail/useFocusPointStyle.test.ts +92 -0
- package/src/components/thumbnail/useFocusPointStyle.tsx +26 -4
- package/types.d.ts +17 -14
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link2.js","sources":["../../../src/components/link/Link.tsx"],"sourcesContent":["import React, { forwardRef, RefObject, useMemo } from 'react';\n\nimport isEmpty from 'lodash/isEmpty';\n\nimport classNames from 'classnames';\n\nimport { Color, ColorVariant, Icon, Size, Typography
|
|
1
|
+
{"version":3,"file":"Link2.js","sources":["../../../src/components/link/Link.tsx"],"sourcesContent":["import React, { forwardRef, RefObject, useMemo } from 'react';\n\nimport isEmpty from 'lodash/isEmpty';\n\nimport classNames from 'classnames';\n\nimport { Color, ColorVariant, Icon, Size, Typography } from '@lumx/react';\nimport { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';\nimport { renderLink } from '@lumx/react/utils/renderLink';\n\ntype HTMLAnchorProps = React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>;\n\n/**\n * Defines the props of the component.\n */\nexport interface LinkProps extends GenericProps {\n /** Color variant. */\n color?: Color;\n /** Lightened or darkened variant of the selected icon color. */\n colorVariant?: ColorVariant;\n /** Link href. */\n href?: HTMLAnchorProps['href'];\n /** Whether the component is disabled or not. */\n isDisabled?: boolean;\n /** Left icon (SVG path). */\n leftIcon?: string;\n /** Custom react component for the link (can be used to inject react router Link). */\n linkAs?: 'a' | any;\n /** Right icon (SVG path). */\n rightIcon?: string;\n /** Link target. */\n target?: HTMLAnchorProps['target'];\n /** Typography variant. */\n typography?: Typography;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'Link';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\nconst getIconSize = (typography?: Typography) => {\n switch (typography) {\n case Typography.display1:\n return Size.m;\n\n case Typography.headline:\n case Typography.title:\n case Typography.custom.title1:\n case Typography.custom.title2:\n case Typography.custom.title3:\n case Typography.custom.title4:\n case Typography.custom.title5:\n case Typography.custom.title6:\n case Typography.body2:\n case Typography.subtitle2:\n return Size.s;\n\n case Typography.body1:\n case Typography.subtitle1:\n return Size.xs;\n\n case Typography.caption:\n case Typography.overline:\n return Size.xxs;\n\n default:\n return Size.s;\n }\n};\n\n/**\n * Link component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const Link: Comp<LinkProps, HTMLAnchorElement | HTMLButtonElement> = forwardRef((props, ref) => {\n const {\n children,\n className,\n color,\n colorVariant,\n disabled,\n isDisabled = disabled,\n href,\n leftIcon,\n linkAs,\n rightIcon,\n target,\n typography,\n ...forwardedProps\n } = props;\n const renderedChildren = useMemo(\n () => (\n <>\n {leftIcon && !isEmpty(leftIcon) && (\n <Icon icon={leftIcon} className={`${CLASSNAME}__left-icon`} size={getIconSize(typography)} />\n )}\n\n {children && (\n <span\n className={classNames(`${CLASSNAME}__content`, {\n [`lumx-typography-${typography}`]: typography,\n })}\n >\n {children}\n </span>\n )}\n\n {rightIcon && !isEmpty(rightIcon) && (\n <Icon icon={rightIcon} className={`${CLASSNAME}__right-icon`} size={getIconSize(typography)} />\n )}\n </>\n ),\n [leftIcon, typography, children, rightIcon],\n );\n\n /**\n * If there is no linkAs prop and no href, we returned a <button> instead of a <a>.\n * If the component is disabled, we also returned a <button> since disabled is not compatible with <a>.\n */\n if ((!linkAs && isEmpty(href)) || isDisabled) {\n return (\n <button\n type=\"button\"\n {...forwardedProps}\n ref={ref as RefObject<HTMLButtonElement>}\n disabled={isDisabled}\n className={classNames(className, handleBasicClasses({ prefix: CLASSNAME, color, colorVariant }))}\n >\n {renderedChildren}\n </button>\n );\n }\n return renderLink(\n {\n linkAs,\n ...forwardedProps,\n href,\n target,\n className: classNames(className, handleBasicClasses({ prefix: CLASSNAME, color, colorVariant })),\n ref: ref as RefObject<HTMLAnchorElement>,\n },\n renderedChildren,\n );\n});\nLink.displayName = COMPONENT_NAME;\nLink.className = CLASSNAME;\n"],"names":["COMPONENT_NAME","CLASSNAME","getRootClassName","getIconSize","typography","Typography","display1","Size","m","headline","title","custom","title1","title2","title3","title4","title5","title6","body2","subtitle2","s","body1","subtitle1","xs","caption","overline","xxs","Link","forwardRef","props","ref","children","className","color","colorVariant","disabled","isDisabled","href","leftIcon","linkAs","rightIcon","target","forwardedProps","renderedChildren","useMemo","isEmpty","classNames","handleBasicClasses","prefix","renderLink","displayName"],"mappings":";;;;;;;;AAoCA;;;AAGA,IAAMA,cAAc,GAAG,MAAvB;AAEA;;;;AAGA,IAAMC,SAAS,GAAGC,gBAAgB,CAACF,cAAD,CAAlC;;AAEA,IAAMG,WAAW,GAAG,SAAdA,WAAc,CAACC,UAAD,EAA6B;AAC7C,UAAQA,UAAR;AACI,SAAKC,UAAU,CAACC,QAAhB;AACI,aAAOC,IAAI,CAACC,CAAZ;;AAEJ,SAAKH,UAAU,CAACI,QAAhB;AACA,SAAKJ,UAAU,CAACK,KAAhB;AACA,SAAKL,UAAU,CAACM,MAAX,CAAkBC,MAAvB;AACA,SAAKP,UAAU,CAACM,MAAX,CAAkBE,MAAvB;AACA,SAAKR,UAAU,CAACM,MAAX,CAAkBG,MAAvB;AACA,SAAKT,UAAU,CAACM,MAAX,CAAkBI,MAAvB;AACA,SAAKV,UAAU,CAACM,MAAX,CAAkBK,MAAvB;AACA,SAAKX,U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,SAAD,EAAYe,kBAAkB,CAAC;AAAEC,MAAAA,MAAM,EAAE/C,SAAV;AAAqBgC,MAAAA,KAAK,EAALA,KAArB;AAA4BC,MAAAA,YAAY,EAAZA;AAA5B,KAAD,CAA9B,CANZ;AAOTJ,IAAAA,GAAG,EAAEA;AAPI,MASba,gBATa,CAAjB;AAWH,CArEqF;AAsEtFhB,IAAI,CAACuB,WAAL,GAAmBlD,cAAnB;AACA2B,IAAI,CAACK,SAAL,GAAiB/B,SAAjB;;;;"}
|
|
@@ -50,23 +50,27 @@ function useImageLoad(imageURL, imgRef) {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
// Calculate shift to center the focus point in the container.
|
|
53
|
-
function shiftPosition(
|
|
53
|
+
function shiftPosition(_ref) {
|
|
54
|
+
var scale = _ref.scale,
|
|
55
|
+
focusPoint = _ref.focusPoint,
|
|
56
|
+
imageSize = _ref.imageSize,
|
|
57
|
+
containerSize = _ref.containerSize;
|
|
58
|
+
if (imageSize === containerSize) return 0;
|
|
54
59
|
var scaledSize = imageSize / scale;
|
|
55
60
|
var scaledFocusHeight = focusPoint * scaledSize;
|
|
56
61
|
var startFocus = scaledFocusHeight - containerSize / 2;
|
|
57
62
|
var shift = startFocus / (scaledSize - containerSize);
|
|
58
63
|
return Math.floor(Math.max(Math.min(shift, 1), 0) * 100);
|
|
59
64
|
}
|
|
60
|
-
|
|
61
65
|
// Compute CSS properties to apply the focus point.
|
|
62
|
-
var useFocusPointStyle = function useFocusPointStyle(
|
|
63
|
-
var image =
|
|
64
|
-
aspectRatio =
|
|
65
|
-
focusPoint =
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
var width =
|
|
69
|
-
height =
|
|
66
|
+
var useFocusPointStyle = function useFocusPointStyle(_ref2, element, isLoaded) {
|
|
67
|
+
var image = _ref2.image,
|
|
68
|
+
aspectRatio = _ref2.aspectRatio,
|
|
69
|
+
focusPoint = _ref2.focusPoint,
|
|
70
|
+
_ref2$imgProps = _ref2.imgProps;
|
|
71
|
+
_ref2$imgProps = _ref2$imgProps === void 0 ? {} : _ref2$imgProps;
|
|
72
|
+
var width = _ref2$imgProps.width,
|
|
73
|
+
height = _ref2$imgProps.height;
|
|
70
74
|
// Get natural image size from imgProps or img element.
|
|
71
75
|
var imageSize = useMemo(function () {
|
|
72
76
|
// Focus point is not applicable => exit early
|
|
@@ -135,10 +139,20 @@ var useFocusPointStyle = function useFocusPointStyle(_ref, element, isLoaded) {
|
|
|
135
139
|
var scale = Math.min(widthScale, heightScale); // Focus Y relative to the top (instead of the center)
|
|
136
140
|
|
|
137
141
|
var focusPointFromTop = Math.abs(((focusPoint === null || focusPoint === void 0 ? void 0 : focusPoint.y) || 0) - 1) / 2;
|
|
138
|
-
var y = shiftPosition(
|
|
142
|
+
var y = shiftPosition({
|
|
143
|
+
scale: scale,
|
|
144
|
+
focusPoint: focusPointFromTop,
|
|
145
|
+
imageSize: imageSize.height,
|
|
146
|
+
containerSize: containerSize.height
|
|
147
|
+
}); // Focus X relative to the left (instead of the center)
|
|
139
148
|
|
|
140
149
|
var focusPointFromLeft = Math.abs(((focusPoint === null || focusPoint === void 0 ? void 0 : focusPoint.x) || 0) + 1) / 2;
|
|
141
|
-
var x = shiftPosition(
|
|
150
|
+
var x = shiftPosition({
|
|
151
|
+
scale: scale,
|
|
152
|
+
focusPoint: focusPointFromLeft,
|
|
153
|
+
imageSize: imageSize.width,
|
|
154
|
+
containerSize: containerSize.width
|
|
155
|
+
});
|
|
142
156
|
var objectPosition = "".concat(x, "% ").concat(y, "%"); // Update only if needed.
|
|
143
157
|
|
|
144
158
|
setStyle(function (oldStyle) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Thumbnail2.js","sources":["../../../src/components/thumbnail/useImageLoad.ts","../../../src/components/thumbnail/useFocusPointStyle.tsx","../../../src/components/thumbnail/Thumbnail.tsx"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nexport type LoadingState = 'isLoading' | 'isLoaded' | 'hasError';\n\nfunction getState(img: HTMLImageElement | null | undefined, event?: Event) {\n // Error event occurred or image loaded empty.\n if (event?.type === 'error' || (img?.complete && (img?.naturalWidth === 0 || img?.naturalHeight === 0))) {\n return 'hasError';\n }\n // Image is undefined or incomplete.\n if (!img || !img.complete) {\n return 'isLoading';\n }\n // Else loaded.\n return 'isLoaded';\n}\n\nexport function useImageLoad(imageURL: string, imgRef?: HTMLImageElement): LoadingState {\n const [state, setState] = useState<LoadingState>(getState(imgRef));\n\n // Update state when changing image URL or DOM reference.\n useEffect(() => {\n setState(getState(imgRef));\n }, [imageURL, imgRef]);\n\n // Listen to `load` and `error` event on image\n useEffect(() => {\n const img = imgRef;\n if (!img) return undefined;\n const update = (event?: Event) => setState(getState(img, event));\n img.addEventListener('load', update);\n img.addEventListener('error', update);\n return () => {\n img.removeEventListener('load', update);\n img.removeEventListener('error', update);\n };\n }, [imgRef, imgRef?.src]);\n\n return state;\n}\n","import { CSSProperties, useEffect, useMemo, useState } from 'react';\nimport { AspectRatio } from '@lumx/react/components';\nimport { ThumbnailProps } from '@lumx/react/components/thumbnail/Thumbnail';\n\n// Calculate shift to center the focus point in the container.\nfunction shiftPosition(scale: number, focusPoint: number, imageSize: number, containerSize: number) {\n const scaledSize = imageSize / scale;\n const scaledFocusHeight = focusPoint * scaledSize;\n const startFocus = scaledFocusHeight - containerSize / 2;\n const shift = startFocus / (scaledSize - containerSize);\n return Math.floor(Math.max(Math.min(shift, 1), 0) * 100);\n}\n\ntype Size = { width: number; height: number };\n\n// Compute CSS properties to apply the focus point.\nexport const useFocusPointStyle = (\n { image, aspectRatio, focusPoint, imgProps: { width, height } = {} }: ThumbnailProps,\n element: HTMLImageElement | undefined,\n isLoaded: boolean,\n): CSSProperties => {\n // Get natural image size from imgProps or img element.\n const imageSize: Size | undefined = useMemo(() => {\n // Focus point is not applicable => exit early\n if (!image || aspectRatio === AspectRatio.original || (!focusPoint?.x && !focusPoint?.y)) return undefined;\n if (typeof width === 'number' && typeof height === 'number') return { width, height };\n if (element && isLoaded) return { width: element.naturalWidth, height: element.naturalHeight };\n return undefined;\n }, [aspectRatio, element, focusPoint?.x, focusPoint?.y, height, image, isLoaded, width]);\n\n // Get container size (dependant on imageSize).\n const [containerSize, setContainerSize] = useState<Size | undefined>(undefined);\n useEffect(\n function updateContainerSize() {\n const cWidth = element?.offsetWidth;\n const cHeight = element?.offsetHeight;\n if (cWidth && cHeight) {\n // Update only if needed.\n setContainerSize((oldContainerSize) =>\n oldContainerSize?.width === cWidth && oldContainerSize.height === cHeight\n ? oldContainerSize\n : { width: cWidth, height: cHeight },\n );\n } else if (imageSize) {\n // Wait for a render (in case the container size is dependent on the image size).\n requestAnimationFrame(updateContainerSize);\n }\n },\n [element?.offsetHeight, element?.offsetWidth, imageSize],\n );\n\n // Compute style.\n const [style, setStyle] = useState<CSSProperties>({});\n useEffect(() => {\n // Focus point is not applicable => exit early\n if (!image || aspectRatio === AspectRatio.original || (!focusPoint?.x && !focusPoint?.y)) {\n return;\n }\n if (!element || !imageSize) {\n // Focus point can be computed but now right now (image size unknown).\n setStyle({ visibility: 'hidden' });\n return;\n }\n if (!containerSize) {\n // Missing container size abort focus point compute.\n setStyle({});\n return;\n }\n\n const heightScale = imageSize.height / containerSize.height;\n const widthScale = imageSize.width / containerSize.width;\n const scale = Math.min(widthScale, heightScale);\n\n // Focus Y relative to the top (instead of the center)\n const focusPointFromTop = Math.abs((focusPoint?.y || 0) - 1) / 2;\n const y = shiftPosition(scale, focusPointFromTop, imageSize.height, containerSize.height);\n\n // Focus X relative to the left (instead of the center)\n const focusPointFromLeft = Math.abs((focusPoint?.x || 0) + 1) / 2;\n const x = shiftPosition(scale, focusPointFromLeft, imageSize.width, containerSize.width);\n\n const objectPosition = `${x}% ${y}%`;\n\n // Update only if needed.\n setStyle((oldStyle) => (oldStyle.objectPosition === objectPosition ? oldStyle : { objectPosition }));\n }, [aspectRatio, containerSize, element, focusPoint?.x, focusPoint?.y, image, imageSize]);\n\n return style;\n};\n","import React, {\n CSSProperties,\n forwardRef,\n ImgHTMLAttributes,\n KeyboardEventHandler,\n MouseEventHandler,\n ReactElement,\n ReactNode,\n Ref,\n useState,\n} from 'react';\nimport classNames from 'classnames';\n\nimport { AspectRatio, HorizontalAlignment, Icon, Size, Theme } from '@lumx/react';\n\nimport { Comp, Falsy, GenericProps, getRootClassName, handleBasicClasses, HasTheme } from '@lumx/react/utils';\n\nimport { mdiImageBroken } from '@lumx/icons';\nimport { mergeRefs } from '@lumx/react/utils/mergeRefs';\nimport { useImageLoad } from '@lumx/react/components/thumbnail/useImageLoad';\nimport { useFocusPointStyle } from '@lumx/react/components/thumbnail/useFocusPointStyle';\nimport { FocusPoint, ThumbnailSize, ThumbnailVariant } from './types';\n\ntype ImgHTMLProps = ImgHTMLAttributes<HTMLImageElement>;\n\n/**\n * Defines the props of the component.\n */\nexport interface ThumbnailProps extends GenericProps, HasTheme {\n /** Alignment of the thumbnail in it's parent (requires flex parent). */\n align?: HorizontalAlignment;\n /** Image alternative text. */\n alt: string;\n /** Image aspect ratio. */\n aspectRatio?: AspectRatio;\n /** Badge. */\n badge?: ReactElement | Falsy;\n /** Image cross origin resource policy. */\n crossOrigin?: ImgHTMLProps['crossOrigin'];\n /** Fallback icon (SVG path) or react node when image fails to load. */\n fallback?: string | ReactNode;\n /** Whether the thumbnail should fill it's parent size (requires flex parent) or not. */\n fillHeight?: boolean;\n /** Apply relative vertical and horizontal shift (from -1 to 1) on the image position inside the thumbnail. */\n focusPoint?: FocusPoint;\n /** Image URL. */\n image: string;\n /** Props to inject into the native <img> element. */\n imgProps?: ImgHTMLProps;\n /** Reference to the native <img> element. */\n imgRef?: Ref<HTMLImageElement>;\n /** Set to true to force the display of the loading skeleton. */\n isLoading?: boolean;\n /** Size variant of the component. */\n size?: ThumbnailSize;\n /** Image loading mode. */\n loading?: ImgHTMLProps['loading'];\n /** On click callback. */\n onClick?: MouseEventHandler<HTMLDivElement>;\n /** On key press callback. */\n onKeyPress?: KeyboardEventHandler<HTMLDivElement>;\n /** Variant of the component. */\n variant?: ThumbnailVariant;\n /** Props to pass to the link wrapping the thumbnail. */\n linkProps?: React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>;\n /** Custom react component for the link (can be used to inject react router Link). */\n linkAs?: 'a' | any;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'Thumbnail';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * Component default props.\n */\nconst DEFAULT_PROPS: Partial<ThumbnailProps> = {\n fallback: mdiImageBroken,\n loading: 'lazy',\n theme: Theme.light,\n};\n\n/**\n * Thumbnail component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const Thumbnail: Comp<ThumbnailProps> = forwardRef((props, ref) => {\n const {\n align,\n alt,\n aspectRatio = AspectRatio.original,\n badge,\n className,\n crossOrigin,\n fallback,\n fillHeight,\n // `focusPoint` needs to be here to remove it from `forwardedProps`.\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n focusPoint,\n image,\n imgProps,\n imgRef: propImgRef,\n isLoading: isLoadingProp,\n loading,\n size,\n theme,\n variant,\n linkProps,\n linkAs,\n ...forwardedProps\n } = props;\n const [imgElement, setImgElement] = useState<HTMLImageElement>();\n\n // Image loading state.\n const loadingState = useImageLoad(image, imgElement);\n const isLoaded = loadingState === 'isLoaded';\n const isLoading = isLoadingProp || loadingState === 'isLoading';\n const hasError = loadingState === 'hasError';\n\n // Focus point.\n const focusPointStyle = useFocusPointStyle(props, imgElement, isLoaded);\n\n const hasIconErrorFallback = hasError && typeof fallback === 'string';\n const hasCustomErrorFallback = hasError && !hasIconErrorFallback;\n const imageErrorStyle: CSSProperties = {};\n if (hasIconErrorFallback) {\n // Keep the image layout on icon fallback.\n imageErrorStyle.visibility = 'hidden';\n } else if (hasCustomErrorFallback) {\n // Remove the image on custom fallback.\n imageErrorStyle.display = 'none';\n }\n\n const isLink = Boolean(linkProps?.href || linkAs);\n const isButton = !!forwardedProps.onClick;\n const isClickable = isButton || isLink;\n\n let Wrapper: any = 'div';\n const wrapperProps = { ...forwardedProps };\n if (isLink) {\n Wrapper = linkAs || 'a';\n Object.assign(wrapperProps, linkProps);\n } else if (isButton) {\n Wrapper = 'button';\n wrapperProps.type = forwardedProps.type || 'button';\n wrapperProps['aria-label'] = forwardedProps['aria-label'] || alt;\n }\n\n return (\n <Wrapper\n {...wrapperProps}\n ref={ref}\n className={classNames(\n linkProps?.className,\n className,\n handleBasicClasses({\n align,\n aspectRatio,\n prefix: CLASSNAME,\n size,\n theme,\n variant,\n isClickable,\n hasError,\n hasIconErrorFallback,\n hasCustomErrorFallback,\n isLoading,\n hasBadge: !!badge,\n }),\n fillHeight && `${CLASSNAME}--fill-height`,\n )}\n >\n <div className={`${CLASSNAME}__background`}>\n <img\n {...imgProps}\n style={{\n ...imgProps?.style,\n ...imageErrorStyle,\n ...focusPointStyle,\n }}\n ref={mergeRefs(setImgElement, propImgRef)}\n className={classNames(\n handleBasicClasses({\n prefix: `${CLASSNAME}__image`,\n isLoading,\n hasDefinedSize: Boolean(imgProps?.height && imgProps.width),\n }),\n imgProps?.className,\n )}\n crossOrigin={crossOrigin}\n src={image}\n alt={alt}\n loading={loading}\n />\n {!isLoading && hasError && (\n <div className={`${CLASSNAME}__fallback`}>\n {hasIconErrorFallback ? (\n <Icon icon={fallback as string} size={Size.xxs} theme={theme} />\n ) : (\n fallback\n )}\n </div>\n )}\n </div>\n {badge &&\n React.cloneElement(badge, { className: classNames(`${CLASSNAME}__badge`, badge.props.className) })}\n </Wrapper>\n );\n});\nThumbnail.displayName = COMPONENT_NAME;\nThumbnail.className = CLASSNAME;\nThumbnail.defaultProps = DEFAULT_PROPS;\n"],"names":["getState","img","event","type","complete","naturalWidth","naturalHeight","useImageLoad","imageURL","imgRef","useState","state","setState","useEffect","undefined","update","addEventListener","removeEventListener","src","shiftPosition","scale","focusPoint","imageSize","containerSize","scaledSize","scaledFocusHeight","startFocus","shift","Math","floor","max","min","useFocusPointStyle","element","isLoaded","image","aspectRatio","imgProps","width","height","useMemo","AspectRatio","original","x","y","setContainerSize","updateContainerSize","cWidth","offsetWidth","cHeight","offsetHeight","oldContainerSize","requestAnimationFrame","style","setStyle","visibility","heightScale","widthScale","focusPointFromTop","abs","focusPointFromLeft","objectPosition","oldStyle","COMPONENT_NAME","CLASSNAME","getRootClassName","DEFAULT_PROPS","fallback","mdiImageBroken","loading","theme","Theme","light","Thumbnail","forwardRef","props","ref","align","alt","badge","className","crossOrigin","fillHeight","propImgRef","isLoadingProp","isLoading","size","variant","linkProps","linkAs","forwardedProps","imgElement","setImgElement","loadingState","hasError","focusPointStyle","hasIconErrorFallback","hasCustomErrorFallback","imageErrorStyle","display","isLink","Boolean","href","isButton","onClick","isClickable","Wrapper","wrapperProps","Object","assign","classNames","handleBasicClasses","prefix","hasBadge","mergeRefs","hasDefinedSize","Size","xxs","React","cloneElement","displayName","defaultProps"],"mappings":";;;;;;;AAIA,SAASA,QAAT,CAAkBC,GAAlB,EAA4DC,KAA5D,EAA2E;AACvE;AACA,MAAI,CAAAA,KAAK,SAAL,IAAAA,KAAK,WAAL,YAAAA,KAAK,CAAEC,IAAP,MAAgB,OAAhB,IAA4B,CAAAF,GAAG,SAAH,IAAAA,GAAG,WAAH,YAAAA,GAAG,CAAEG,QAAL,MAAkB,CAAAH,GAAG,SAAH,IAAAA,GAAG,WAAH,YAAAA,GAAG,CAAEI,YAAL,MAAsB,CAAtB,IAA2B,CAAAJ,GAAG,SAAH,IAAAA,GAAG,WAAH,YAAAA,GAAG,CAAEK,aAAL,MAAuB,CAApE,CAAhC,EAAyG;AACrG,WAAO,UAAP;AACH,GAJsE;;;AAMvE,MAAI,CAACL,GAAD,IAAQ,CAACA,GAAG,CAACG,QAAjB,EAA2B;AACvB,WAAO,WAAP;AACH,GARsE;;;AAUvE,SAAO,UAAP;AACH;;AAEM,SAASG,YAAT,CAAsB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C,IAAD;AAAM,IAAA,IAAI,EAAE7B,QAAZ;AAAgC,IAAA,IAAI,EAAEiD,IAAI,CAACC,GAA3C;AAAgD,IAAA,KAAK,EAAE/C;AAAvD,IADiB,GAGjBH,QAJR,CAvBR,CAvBJ,EAuDKY,KAAK,IACFuC,KAAK,CAACC,YAAN,CAAmBxC,KAAnB,EAA0B;AAAEC,IAAAA,SAAS,EAAE8B,UAAU,WAAI9C,SAAJ,cAAwBe,KAAK,CAACJ,KAAN,CAAYK,SAApC;AAAvB,GAA1B,CAxDR,CADJ;AA4DH,CA1HwD;AA2HzDP,SAAS,CAAC+C,WAAV,GAAwBzD,cAAxB;AACAU,SAAS,CAACO,SAAV,GAAsBhB,SAAtB;AACAS,SAAS,CAACgD,YAAV,GAAyBvD,aAAzB;;;;"}
|
|
1
|
+
{"version":3,"file":"Thumbnail2.js","sources":["../../../src/components/thumbnail/useImageLoad.ts","../../../src/components/thumbnail/useFocusPointStyle.tsx","../../../src/components/thumbnail/Thumbnail.tsx"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nexport type LoadingState = 'isLoading' | 'isLoaded' | 'hasError';\n\nfunction getState(img: HTMLImageElement | null | undefined, event?: Event) {\n // Error event occurred or image loaded empty.\n if (event?.type === 'error' || (img?.complete && (img?.naturalWidth === 0 || img?.naturalHeight === 0))) {\n return 'hasError';\n }\n // Image is undefined or incomplete.\n if (!img || !img.complete) {\n return 'isLoading';\n }\n // Else loaded.\n return 'isLoaded';\n}\n\nexport function useImageLoad(imageURL: string, imgRef?: HTMLImageElement): LoadingState {\n const [state, setState] = useState<LoadingState>(getState(imgRef));\n\n // Update state when changing image URL or DOM reference.\n useEffect(() => {\n setState(getState(imgRef));\n }, [imageURL, imgRef]);\n\n // Listen to `load` and `error` event on image\n useEffect(() => {\n const img = imgRef;\n if (!img) return undefined;\n const update = (event?: Event) => setState(getState(img, event));\n img.addEventListener('load', update);\n img.addEventListener('error', update);\n return () => {\n img.removeEventListener('load', update);\n img.removeEventListener('error', update);\n };\n }, [imgRef, imgRef?.src]);\n\n return state;\n}\n","import { CSSProperties, useEffect, useMemo, useState } from 'react';\nimport { AspectRatio } from '@lumx/react/components';\nimport { ThumbnailProps } from '@lumx/react/components/thumbnail/Thumbnail';\n\n// Calculate shift to center the focus point in the container.\nexport function shiftPosition({\n scale,\n focusPoint,\n imageSize,\n containerSize,\n}: {\n scale: number;\n focusPoint: number;\n imageSize: number;\n containerSize: number;\n}) {\n if (imageSize === containerSize) return 0;\n const scaledSize = imageSize / scale;\n\n const scaledFocusHeight = focusPoint * scaledSize;\n const startFocus = scaledFocusHeight - containerSize / 2;\n const shift = startFocus / (scaledSize - containerSize);\n\n return Math.floor(Math.max(Math.min(shift, 1), 0) * 100);\n}\n\ntype Size = { width: number; height: number };\n\n// Compute CSS properties to apply the focus point.\nexport const useFocusPointStyle = (\n { image, aspectRatio, focusPoint, imgProps: { width, height } = {} }: ThumbnailProps,\n element: HTMLImageElement | undefined,\n isLoaded: boolean,\n): CSSProperties => {\n // Get natural image size from imgProps or img element.\n const imageSize: Size | undefined = useMemo(() => {\n // Focus point is not applicable => exit early\n if (!image || aspectRatio === AspectRatio.original || (!focusPoint?.x && !focusPoint?.y)) return undefined;\n if (typeof width === 'number' && typeof height === 'number') return { width, height };\n if (element && isLoaded) return { width: element.naturalWidth, height: element.naturalHeight };\n return undefined;\n }, [aspectRatio, element, focusPoint?.x, focusPoint?.y, height, image, isLoaded, width]);\n\n // Get container size (dependant on imageSize).\n const [containerSize, setContainerSize] = useState<Size | undefined>(undefined);\n useEffect(\n function updateContainerSize() {\n const cWidth = element?.offsetWidth;\n const cHeight = element?.offsetHeight;\n if (cWidth && cHeight) {\n // Update only if needed.\n setContainerSize((oldContainerSize) =>\n oldContainerSize?.width === cWidth && oldContainerSize.height === cHeight\n ? oldContainerSize\n : { width: cWidth, height: cHeight },\n );\n } else if (imageSize) {\n // Wait for a render (in case the container size is dependent on the image size).\n requestAnimationFrame(updateContainerSize);\n }\n },\n [element?.offsetHeight, element?.offsetWidth, imageSize],\n );\n\n // Compute style.\n const [style, setStyle] = useState<CSSProperties>({});\n useEffect(() => {\n // Focus point is not applicable => exit early\n if (!image || aspectRatio === AspectRatio.original || (!focusPoint?.x && !focusPoint?.y)) {\n return;\n }\n if (!element || !imageSize) {\n // Focus point can be computed but now right now (image size unknown).\n setStyle({ visibility: 'hidden' });\n return;\n }\n if (!containerSize) {\n // Missing container size abort focus point compute.\n setStyle({});\n return;\n }\n\n const heightScale = imageSize.height / containerSize.height;\n const widthScale = imageSize.width / containerSize.width;\n const scale = Math.min(widthScale, heightScale);\n\n // Focus Y relative to the top (instead of the center)\n const focusPointFromTop = Math.abs((focusPoint?.y || 0) - 1) / 2;\n const y = shiftPosition({\n scale,\n focusPoint: focusPointFromTop,\n imageSize: imageSize.height,\n containerSize: containerSize.height,\n });\n\n // Focus X relative to the left (instead of the center)\n const focusPointFromLeft = Math.abs((focusPoint?.x || 0) + 1) / 2;\n const x = shiftPosition({\n scale,\n focusPoint: focusPointFromLeft,\n imageSize: imageSize.width,\n containerSize: containerSize.width,\n });\n\n const objectPosition = `${x}% ${y}%`;\n // Update only if needed.\n setStyle((oldStyle) => (oldStyle.objectPosition === objectPosition ? oldStyle : { objectPosition }));\n }, [aspectRatio, containerSize, element, focusPoint?.x, focusPoint?.y, image, imageSize]);\n\n return style;\n};\n","import React, {\n CSSProperties,\n forwardRef,\n ImgHTMLAttributes,\n KeyboardEventHandler,\n MouseEventHandler,\n ReactElement,\n ReactNode,\n Ref,\n useState,\n} from 'react';\nimport classNames from 'classnames';\n\nimport { AspectRatio, HorizontalAlignment, Icon, Size, Theme } from '@lumx/react';\n\nimport { Comp, Falsy, GenericProps, getRootClassName, handleBasicClasses, HasTheme } from '@lumx/react/utils';\n\nimport { mdiImageBroken } from '@lumx/icons';\nimport { mergeRefs } from '@lumx/react/utils/mergeRefs';\nimport { useImageLoad } from '@lumx/react/components/thumbnail/useImageLoad';\nimport { useFocusPointStyle } from '@lumx/react/components/thumbnail/useFocusPointStyle';\nimport { FocusPoint, ThumbnailSize, ThumbnailVariant } from './types';\n\ntype ImgHTMLProps = ImgHTMLAttributes<HTMLImageElement>;\n\n/**\n * Defines the props of the component.\n */\nexport interface ThumbnailProps extends GenericProps, HasTheme {\n /** Alignment of the thumbnail in it's parent (requires flex parent). */\n align?: HorizontalAlignment;\n /** Image alternative text. */\n alt: string;\n /** Image aspect ratio. */\n aspectRatio?: AspectRatio;\n /** Badge. */\n badge?: ReactElement | Falsy;\n /** Image cross origin resource policy. */\n crossOrigin?: ImgHTMLProps['crossOrigin'];\n /** Fallback icon (SVG path) or react node when image fails to load. */\n fallback?: string | ReactNode;\n /** Whether the thumbnail should fill it's parent size (requires flex parent) or not. */\n fillHeight?: boolean;\n /** Apply relative vertical and horizontal shift (from -1 to 1) on the image position inside the thumbnail. */\n focusPoint?: FocusPoint;\n /** Image URL. */\n image: string;\n /** Props to inject into the native <img> element. */\n imgProps?: ImgHTMLProps;\n /** Reference to the native <img> element. */\n imgRef?: Ref<HTMLImageElement>;\n /** Set to true to force the display of the loading skeleton. */\n isLoading?: boolean;\n /** Size variant of the component. */\n size?: ThumbnailSize;\n /** Image loading mode. */\n loading?: ImgHTMLProps['loading'];\n /** On click callback. */\n onClick?: MouseEventHandler<HTMLDivElement>;\n /** On key press callback. */\n onKeyPress?: KeyboardEventHandler<HTMLDivElement>;\n /** Variant of the component. */\n variant?: ThumbnailVariant;\n /** Props to pass to the link wrapping the thumbnail. */\n linkProps?: React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>;\n /** Custom react component for the link (can be used to inject react router Link). */\n linkAs?: 'a' | any;\n}\n\n/**\n * Component display name.\n */\nconst COMPONENT_NAME = 'Thumbnail';\n\n/**\n * Component default class name and class prefix.\n */\nconst CLASSNAME = getRootClassName(COMPONENT_NAME);\n\n/**\n * Component default props.\n */\nconst DEFAULT_PROPS: Partial<ThumbnailProps> = {\n fallback: mdiImageBroken,\n loading: 'lazy',\n theme: Theme.light,\n};\n\n/**\n * Thumbnail component.\n *\n * @param props Component props.\n * @param ref Component ref.\n * @return React element.\n */\nexport const Thumbnail: Comp<ThumbnailProps> = forwardRef((props, ref) => {\n const {\n align,\n alt,\n aspectRatio = AspectRatio.original,\n badge,\n className,\n crossOrigin,\n fallback,\n fillHeight,\n // `focusPoint` needs to be here to remove it from `forwardedProps`.\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n focusPoint,\n image,\n imgProps,\n imgRef: propImgRef,\n isLoading: isLoadingProp,\n loading,\n size,\n theme,\n variant,\n linkProps,\n linkAs,\n ...forwardedProps\n } = props;\n const [imgElement, setImgElement] = useState<HTMLImageElement>();\n\n // Image loading state.\n const loadingState = useImageLoad(image, imgElement);\n const isLoaded = loadingState === 'isLoaded';\n const isLoading = isLoadingProp || loadingState === 'isLoading';\n const hasError = loadingState === 'hasError';\n\n // Focus point.\n const focusPointStyle = useFocusPointStyle(props, imgElement, isLoaded);\n\n const hasIconErrorFallback = hasError && typeof fallback === 'string';\n const hasCustomErrorFallback = hasError && !hasIconErrorFallback;\n const imageErrorStyle: CSSProperties = {};\n if (hasIconErrorFallback) {\n // Keep the image layout on icon fallback.\n imageErrorStyle.visibility = 'hidden';\n } else if (hasCustomErrorFallback) {\n // Remove the image on custom fallback.\n imageErrorStyle.display = 'none';\n }\n\n const isLink = Boolean(linkProps?.href || linkAs);\n const isButton = !!forwardedProps.onClick;\n const isClickable = isButton || isLink;\n\n let Wrapper: any = 'div';\n const wrapperProps = { ...forwardedProps };\n if (isLink) {\n Wrapper = linkAs || 'a';\n Object.assign(wrapperProps, linkProps);\n } else if (isButton) {\n Wrapper = 'button';\n wrapperProps.type = forwardedProps.type || 'button';\n wrapperProps['aria-label'] = forwardedProps['aria-label'] || alt;\n }\n\n return (\n <Wrapper\n {...wrapperProps}\n ref={ref}\n className={classNames(\n linkProps?.className,\n className,\n handleBasicClasses({\n align,\n aspectRatio,\n prefix: CLASSNAME,\n size,\n theme,\n variant,\n isClickable,\n hasError,\n hasIconErrorFallback,\n hasCustomErrorFallback,\n isLoading,\n hasBadge: !!badge,\n }),\n fillHeight && `${CLASSNAME}--fill-height`,\n )}\n >\n <div className={`${CLASSNAME}__background`}>\n <img\n {...imgProps}\n style={{\n ...imgProps?.style,\n ...imageErrorStyle,\n ...focusPointStyle,\n }}\n ref={mergeRefs(setImgElement, propImgRef)}\n className={classNames(\n handleBasicClasses({\n prefix: `${CLASSNAME}__image`,\n isLoading,\n hasDefinedSize: Boolean(imgProps?.height && imgProps.width),\n }),\n imgProps?.className,\n )}\n crossOrigin={crossOrigin}\n src={image}\n alt={alt}\n loading={loading}\n />\n {!isLoading && hasError && (\n <div className={`${CLASSNAME}__fallback`}>\n {hasIconErrorFallback ? (\n <Icon icon={fallback as string} size={Size.xxs} theme={theme} />\n ) : (\n fallback\n )}\n </div>\n )}\n </div>\n {badge &&\n React.cloneElement(badge, { className: classNames(`${CLASSNAME}__badge`, badge.props.className) })}\n </Wrapper>\n );\n});\nThumbnail.displayName = COMPONENT_NAME;\nThumbnail.className = CLASSNAME;\nThumbnail.defaultProps = DEFAULT_PROPS;\n"],"names":["getState","img","event","type","complete","naturalWidth","naturalHeight","useImageLoad","imageURL","imgRef","useState","state","setState","useEffect","undefined","update","addEventListener","removeEventListener","src","shiftPosition","scale","focusPoint","imageSize","containerSize","scaledSize","scaledFocusHeight","startFocus","shift","Math","floor","max","min","useFocusPointStyle","element","isLoaded","image","aspectRatio","imgProps","width","height","useMemo","AspectRatio","original","x","y","setContainerSize","updateContainerSize","cWidth","offsetWidth","cHeight","offsetHeight","oldContainerSize","requestAnimationFrame","style","setStyle","visibility","heightScale","widthScale","focusPointFromTop","abs","focusPointFromLeft","objectPosition","oldStyle","COMPONENT_NAME","CLASSNAME","getRootClassName","DEFAULT_PROPS","fallback","mdiImageBroken","loading","theme","Theme","light","Thumbnail","forwardRef","props","ref","align","alt","badge","className","crossOrigin","fillHeight","propImgRef","isLoadingProp","isLoading","size","variant","linkProps","linkAs","forwardedProps","imgElement","setImgElement","loadingState","hasError","focusPointStyle","hasIconErrorFallback","hasCustomErrorFallback","imageErrorStyle","display","isLink","Boolean","href","isButton","onClick","isClickable","Wrapper","wrapperProps","Object","assign","classNames","handleBasicClasses","prefix","hasBadge","mergeRefs","hasDefinedSize","Size","xxs","React","cloneElement","displayName","defaultProps"],"mappings":";;;;;;;AAIA,SAASA,QAAT,CAAkBC,GAAlB,EAA4DC,KAA5D,EAA2E;AACvE;AACA,MAAI,CAAAA,KAAK,SAAL,IAAAA,KAAK,WAAL,YAAAA,KAAK,CAAEC,IAAP,MAAgB,OAAhB,IAA4B,CAAAF,GAAG,SAAH,IAAAA,GAAG,WAAH,YAAAA,GAAG,CAAEG,QAAL,MAAkB,CAAAH,GAAG,SAAH,IAAAA,GAAG,WAAH,YAAAA,GAAG,CAAEI,YAAL,MAAsB,CAAtB,IAA2B,CAAAJ,GAAG,SAAH,IAAAA,GAAG,WAAH,YAAAA,GAAG,CAAEK,aAAL,MAAuB,CAApE,CAAhC,EAAyG;AACrG,WAAO,UAAP;AACH,GAJsE;;;AAMvE,MAAI,CAACL,GAAD,IAAQ,CAACA,GAAG,CAACG,QAAjB,EAA2B;AACvB,WAAO,WAAP;AACH,GARsE;;;AAUvE,SAAO,UAAP;AACH;;AAEM,SAASG,YAAT,CAAsBC,QAAtB,EAAwCC,MAAxC,EAAiF;AAAA,kBAC1DC,QAAQ,CAAeV,QAAQ,CAACS,MAAD,CAAvB,CADkD;AAAA;AAAA,MAC7EE,KAD6E;AAAA,MACtEC,QADsE;;;AAIpFC,EAAAA,SAAS,CAAC,YAAM;AACZD,IAAAA,QAAQ,CAACZ,QAAQ,CAACS,MAAD,CAAT,CAAR;AACH,GAFQ,EAEN,CAACD,QAAD,EAAWC,MAAX,CAFM,CAAT,CAJoF;;AASpFI,EAAAA,SAAS,CAAC,YAAM;AACZ,QAAMZ,GAAG,GAAGQ,MAAZ;AACA,QAAI,CAACR,GAAL,E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IAAA,KAAK,EAAE/C;AAAvD,IADiB,GAGjBH,QAJR,CAvBR,CAvBJ,EAuDKY,KAAK,IACFuC,KAAK,CAACC,YAAN,CAAmBxC,KAAnB,EAA0B;AAAEC,IAAAA,SAAS,EAAE8B,UAAU,WAAI9C,SAAJ,cAAwBe,KAAK,CAACJ,KAAN,CAAYK,SAApC;AAAvB,GAA1B,CAxDR,CADJ;AA4DH,CA1HwD;AA2HzDP,SAAS,CAAC+C,WAAV,GAAwBzD,cAAxB;AACAU,SAAS,CAACO,SAAV,GAAsBhB,SAAtB;AACAS,SAAS,CAACgD,YAAV,GAAyBvD,aAAzB;;;;"}
|
|
@@ -103,12 +103,12 @@ var TypographyTitleCustom = {
|
|
|
103
103
|
* List of typographies that can be customized (via CSS variables).
|
|
104
104
|
*/
|
|
105
105
|
var TypographyCustom = _objectSpread2({}, TypographyTitleCustom, {
|
|
106
|
-
intro: 'intro',
|
|
107
|
-
'body-large': 'body-large',
|
|
108
|
-
body: 'body',
|
|
109
|
-
quote: 'quote',
|
|
110
|
-
'publish-info': 'publish-info',
|
|
111
|
-
button: 'button'
|
|
106
|
+
intro: 'custom-intro',
|
|
107
|
+
'body-large': 'custom-body-large',
|
|
108
|
+
body: 'custom-body',
|
|
109
|
+
quote: 'custom-quote',
|
|
110
|
+
'publish-info': 'custom-publish-info',
|
|
111
|
+
button: 'custom-button'
|
|
112
112
|
});
|
|
113
113
|
|
|
114
114
|
/**
|
|
@@ -151,5 +151,5 @@ var Kind = {
|
|
|
151
151
|
error: 'error'
|
|
152
152
|
};
|
|
153
153
|
|
|
154
|
-
export { Alignment, AspectRatio, ColorPalette, ColorVariant, Emphasis, Kind, Orientation, Size, Theme, Typography, TypographyInterface, TypographyTitleCustom };
|
|
154
|
+
export { Alignment, AspectRatio, ColorPalette, ColorVariant, Emphasis, Kind, Orientation, Size, Theme, Typography, TypographyCustom, TypographyInterface, TypographyTitleCustom };
|
|
155
155
|
//# sourceMappingURL=components.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.js","sources":["../../../src/components/index.ts"],"sourcesContent":["import { ValueOf } from '@lumx/react/utils';\n\n/**\n * Alignments.\n */\nexport const Alignment = {\n bottom: 'bottom',\n center: 'center',\n end: 'end',\n left: 'left',\n right: 'right',\n spaceAround: 'space-around',\n spaceBetween: 'space-between',\n start: 'start',\n top: 'top',\n} as const;\nexport type Alignment = ValueOf<typeof Alignment>;\nexport type VerticalAlignment = Extract<Alignment, 'top' | 'center' | 'bottom'>;\nexport type HorizontalAlignment = Extract<Alignment, 'right' | 'center' | 'left'>;\n\n/**\n * See SCSS variable $lumx-color-palette\n */\nexport const ColorPalette = {\n primary: 'primary',\n secondary: 'secondary',\n blue: 'blue',\n dark: 'dark',\n green: 'green',\n yellow: 'yellow',\n red: 'red',\n light: 'light',\n grey: 'grey',\n} as const;\nexport type ColorPalette = ValueOf<typeof ColorPalette>;\nexport type Color = ColorPalette | string;\n\n/**\n * See SCSS variable $lumx-color-variants\n */\nexport const ColorVariant = {\n D1: 'D1',\n D2: 'D2',\n L1: 'L1',\n L2: 'L2',\n L3: 'L3',\n L4: 'L4',\n L5: 'L5',\n L6: 'L6',\n N: 'N',\n} as const;\nexport type ColorVariant = ValueOf<typeof ColorVariant>;\n\nexport const Theme = {\n light: 'light',\n dark: 'dark',\n} as const;\nexport type Theme = ValueOf<typeof Theme>;\n\nexport const Size = {\n xxs: 'xxs',\n xs: 'xs',\n s: 's',\n m: 'm',\n l: 'l',\n xl: 'xl',\n xxl: 'xxl',\n tiny: 'tiny',\n regular: 'regular',\n medium: 'medium',\n big: 'big',\n huge: 'huge',\n} as const;\nexport type Size = ValueOf<typeof Size>;\nexport type GlobalSize = Extract<Size, 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl'>;\n\nexport const Orientation = {\n horizontal: 'horizontal',\n vertical: 'vertical',\n} as const;\nexport type Orientation = ValueOf<typeof Orientation>;\n\nexport const Emphasis = {\n low: 'low',\n medium: 'medium',\n high: 'high',\n} as const;\nexport type Emphasis = ValueOf<typeof Emphasis>;\n\n/**\n * List of typographies that can't be customized.\n */\nexport const TypographyInterface = {\n overline: 'overline',\n caption: 'caption',\n body1: 'body1',\n body2: 'body2',\n subtitle1: 'subtitle1',\n subtitle2: 'subtitle2',\n title: 'title',\n headline: 'headline',\n display1: 'display1',\n} as const;\nexport type TypographyInterface = ValueOf<typeof TypographyInterface>;\n\n/**\n * List of title typographies that can be customized (via CSS variables).\n */\nexport const TypographyTitleCustom = {\n title1: 'custom-title1',\n title2: 'custom-title2',\n title3: 'custom-title3',\n title4: 'custom-title4',\n title5: 'custom-title5',\n title6: 'custom-title6',\n} as const;\nexport type TypographyTitleCustom = ValueOf<typeof TypographyTitleCustom>;\n\n/**\n * List of typographies that can be customized (via CSS variables).\n */\
|
|
1
|
+
{"version":3,"file":"components.js","sources":["../../../src/components/index.ts"],"sourcesContent":["import { ValueOf } from '@lumx/react/utils';\n\n/**\n * Alignments.\n */\nexport const Alignment = {\n bottom: 'bottom',\n center: 'center',\n end: 'end',\n left: 'left',\n right: 'right',\n spaceAround: 'space-around',\n spaceBetween: 'space-between',\n start: 'start',\n top: 'top',\n} as const;\nexport type Alignment = ValueOf<typeof Alignment>;\nexport type VerticalAlignment = Extract<Alignment, 'top' | 'center' | 'bottom'>;\nexport type HorizontalAlignment = Extract<Alignment, 'right' | 'center' | 'left'>;\n\n/**\n * See SCSS variable $lumx-color-palette\n */\nexport const ColorPalette = {\n primary: 'primary',\n secondary: 'secondary',\n blue: 'blue',\n dark: 'dark',\n green: 'green',\n yellow: 'yellow',\n red: 'red',\n light: 'light',\n grey: 'grey',\n} as const;\nexport type ColorPalette = ValueOf<typeof ColorPalette>;\nexport type Color = ColorPalette | string;\n\n/**\n * See SCSS variable $lumx-color-variants\n */\nexport const ColorVariant = {\n D1: 'D1',\n D2: 'D2',\n L1: 'L1',\n L2: 'L2',\n L3: 'L3',\n L4: 'L4',\n L5: 'L5',\n L6: 'L6',\n N: 'N',\n} as const;\nexport type ColorVariant = ValueOf<typeof ColorVariant>;\n\nexport const Theme = {\n light: 'light',\n dark: 'dark',\n} as const;\nexport type Theme = ValueOf<typeof Theme>;\n\nexport const Size = {\n xxs: 'xxs',\n xs: 'xs',\n s: 's',\n m: 'm',\n l: 'l',\n xl: 'xl',\n xxl: 'xxl',\n tiny: 'tiny',\n regular: 'regular',\n medium: 'medium',\n big: 'big',\n huge: 'huge',\n} as const;\nexport type Size = ValueOf<typeof Size>;\nexport type GlobalSize = Extract<Size, 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl'>;\n\nexport const Orientation = {\n horizontal: 'horizontal',\n vertical: 'vertical',\n} as const;\nexport type Orientation = ValueOf<typeof Orientation>;\n\nexport const Emphasis = {\n low: 'low',\n medium: 'medium',\n high: 'high',\n} as const;\nexport type Emphasis = ValueOf<typeof Emphasis>;\n\n/**\n * List of typographies that can't be customized.\n */\nexport const TypographyInterface = {\n overline: 'overline',\n caption: 'caption',\n body1: 'body1',\n body2: 'body2',\n subtitle1: 'subtitle1',\n subtitle2: 'subtitle2',\n title: 'title',\n headline: 'headline',\n display1: 'display1',\n} as const;\nexport type TypographyInterface = ValueOf<typeof TypographyInterface>;\n\n/**\n * List of title typographies that can be customized (via CSS variables).\n */\nexport const TypographyTitleCustom = {\n title1: 'custom-title1',\n title2: 'custom-title2',\n title3: 'custom-title3',\n title4: 'custom-title4',\n title5: 'custom-title5',\n title6: 'custom-title6',\n} as const;\nexport type TypographyTitleCustom = ValueOf<typeof TypographyTitleCustom>;\n\n/**\n * List of typographies that can be customized (via CSS variables).\n */\nexport const TypographyCustom = {\n ...TypographyTitleCustom,\n intro: 'custom-intro',\n 'body-large': 'custom-body-large',\n body: 'custom-body',\n quote: 'custom-quote',\n 'publish-info': 'custom-publish-info',\n button: 'custom-button',\n} as const;\nexport type TypographyCustom = ValueOf<typeof TypographyCustom>;\n\n/**\n * List of all typographies.\n */\nexport const Typography = {\n ...TypographyInterface,\n custom: TypographyCustom,\n} as const;\nexport type Typography = TypographyInterface | TypographyCustom;\n\n/**\n * All available aspect ratios.\n */\nexport const AspectRatio = {\n /** Intrinsic content ratio. */\n original: 'original',\n /** Ratio 16:9 */\n wide: 'wide',\n /** Ratio 3:2 */\n horizontal: 'horizontal',\n /** Ratio 3:2 */\n vertical: 'vertical',\n /** Ratio 1:1 */\n square: 'square',\n /** Ratio constrained by the parent. */\n free: 'free',\n} as const;\nexport type AspectRatio = ValueOf<typeof AspectRatio>;\n\n/**\n * Semantic info about the purpose of the component\n */\nexport const Kind = {\n info: 'info',\n success: 'success',\n warning: 'warning',\n error: 'error',\n} as const;\nexport type Kind = ValueOf<typeof Kind>;\n"],"names":["Alignment","bottom","center","end","left","right","spaceAround","spaceBetween","start","top","ColorPalette","primary","secondary","blue","dark","green","yellow","red","light","grey","ColorVariant","D1","D2","L1","L2","L3","L4","L5","L6","N","Theme","Size","xxs","xs","s","m","l","xl","xxl","tiny","regular","medium","big","huge","Orientation","horizontal","vertical","Emphasis","low","high","TypographyInterface","overline","caption","body1","body2","subtitle1","subtitle2","title","headline","display1","TypographyTitleCustom","title1","title2","title3","title4","title5","title6","TypographyCustom","intro","body","quote","button","Typography","custom","AspectRatio","original","wide","square","free","Kind","info","success","warning","error"],"mappings":";;AAEA;;;IAGaA,SAAS,GAAG;AACrBC,EAAAA,MAAM,EAAE,QADa;AAErBC,EAAAA,MAAM,EAAE,QAFa;AAGrBC,EAAAA,GAAG,EAAE,KAHgB;AAIrBC,EAAAA,IAAI,EAAE,MAJe;AAKrBC,EAAAA,KAAK,EAAE,OALc;AAMrBC,EAAAA,WAAW,EAAE,cANQ;AAOrBC,EAAAA,YAAY,EAAE,eAPO;AAQrBC,EAAAA,KAAK,EAAE,OARc;AASrBC,EAAAA,GAAG,EAAE;AATgB;;AAezB;;;IAGaC,YAAY,GAAG;AACxBC,EAAAA,OAAO,EAAE,SADe;AAExBC,EAAAA,SAAS,EAAE,WAFa;AAGxBC,EAAAA,I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IAAI,EAAE,MADU;AAEhBC,EAAAA,OAAO,EAAE,SAFO;AAGhBC,EAAAA,OAAO,EAAE,SAHO;AAIhBC,EAAAA,KAAK,EAAE;AAJS;;;;"}
|
package/esm/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import './_internal/_rollupPluginBabelHelpers.js';
|
|
2
|
-
export { Alignment, AspectRatio, ColorPalette, ColorVariant, Emphasis, Kind, Orientation, Size, Theme, Typography, TypographyInterface, TypographyTitleCustom } from './_internal/components.js';
|
|
2
|
+
export { Alignment, AspectRatio, ColorPalette, ColorVariant, Emphasis, Kind, Orientation, Size, Theme, Typography, TypographyCustom, TypographyInterface, TypographyTitleCustom } from './_internal/components.js';
|
|
3
3
|
import 'react';
|
|
4
4
|
import './_internal/getRootClassName.js';
|
|
5
5
|
export { I as Icon } from './_internal/Icon2.js';
|
package/package.json
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@juggle/resize-observer": "^3.2.0",
|
|
10
|
-
"@lumx/core": "^2.2.
|
|
11
|
-
"@lumx/icons": "^2.2.
|
|
10
|
+
"@lumx/core": "^2.2.23",
|
|
11
|
+
"@lumx/icons": "^2.2.23",
|
|
12
12
|
"@popperjs/core": "^2.5.4",
|
|
13
13
|
"body-scroll-lock": "^3.1.5",
|
|
14
14
|
"classnames": "^2.2.6",
|
|
@@ -120,6 +120,6 @@
|
|
|
120
120
|
"build:storybook": "cd storybook && ./build"
|
|
121
121
|
},
|
|
122
122
|
"sideEffects": false,
|
|
123
|
-
"version": "2.2.
|
|
124
|
-
"gitHead": "
|
|
123
|
+
"version": "2.2.23",
|
|
124
|
+
"gitHead": "51fd4513c5b083425f263464cbb1e739ab61ac18"
|
|
125
125
|
}
|
package/src/components/index.ts
CHANGED
|
@@ -119,14 +119,14 @@ export type TypographyTitleCustom = ValueOf<typeof TypographyTitleCustom>;
|
|
|
119
119
|
/**
|
|
120
120
|
* List of typographies that can be customized (via CSS variables).
|
|
121
121
|
*/
|
|
122
|
-
const TypographyCustom = {
|
|
122
|
+
export const TypographyCustom = {
|
|
123
123
|
...TypographyTitleCustom,
|
|
124
|
-
intro: 'intro',
|
|
125
|
-
'body-large': 'body-large',
|
|
126
|
-
body: 'body',
|
|
127
|
-
quote: 'quote',
|
|
128
|
-
'publish-info': 'publish-info',
|
|
129
|
-
button: 'button',
|
|
124
|
+
intro: 'custom-intro',
|
|
125
|
+
'body-large': 'custom-body-large',
|
|
126
|
+
body: 'custom-body',
|
|
127
|
+
quote: 'custom-quote',
|
|
128
|
+
'publish-info': 'custom-publish-info',
|
|
129
|
+
button: 'custom-button',
|
|
130
130
|
} as const;
|
|
131
131
|
export type TypographyCustom = ValueOf<typeof TypographyCustom>;
|
|
132
132
|
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
/* eslint-disable jsx-a11y/anchor-is-valid */
|
|
2
2
|
import { mdiChevronDown, mdiLink } from '@lumx/icons';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
ColorPalette,
|
|
5
|
+
ColorVariant,
|
|
6
|
+
Link,
|
|
7
|
+
Typography,
|
|
8
|
+
TypographyCustom,
|
|
9
|
+
TypographyInterface,
|
|
10
|
+
TypographyTitleCustom,
|
|
11
|
+
} from '@lumx/react';
|
|
4
12
|
import { boolean, select, text } from '@storybook/addon-knobs';
|
|
5
13
|
import React, { Fragment } from 'react';
|
|
6
14
|
|
|
@@ -13,7 +21,7 @@ const linkTypographies = { ...TypographyInterface, ...TypographyTitleCustom };
|
|
|
13
21
|
export const SimpleLink = () => (
|
|
14
22
|
<>
|
|
15
23
|
<Link
|
|
16
|
-
href={text('href', 'https://
|
|
24
|
+
href={text('href', 'https://example.com', 'Link 1')}
|
|
17
25
|
target={boolean('target: _blank', false, 'Link 1') ? '_blank' : ''}
|
|
18
26
|
color={select('Color', ColorPalette, ColorPalette.blue, 'Link 1')}
|
|
19
27
|
colorVariant={select('Color Variant', ColorVariant, ColorVariant.N, 'Link 1')}
|
|
@@ -51,14 +59,16 @@ export const WithoutHref = () => (
|
|
|
51
59
|
</div>
|
|
52
60
|
);
|
|
53
61
|
|
|
54
|
-
const
|
|
55
|
-
React.
|
|
62
|
+
export const WithCustomLink = () => {
|
|
63
|
+
const CustomLink: React.FC = ({ children, ...props }) =>
|
|
64
|
+
React.createElement('a', { ...props, style: { color: 'red' } }, children);
|
|
56
65
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
);
|
|
66
|
+
return (
|
|
67
|
+
<Link linkAs={CustomLink} href="https://example.com">
|
|
68
|
+
Custom link
|
|
69
|
+
</Link>
|
|
70
|
+
);
|
|
71
|
+
};
|
|
62
72
|
|
|
63
73
|
export const DisabledLink = () => (
|
|
64
74
|
// eslint-disable-next-line jsx-a11y/anchor-is-valid
|
|
@@ -67,36 +77,6 @@ export const DisabledLink = () => (
|
|
|
67
77
|
</Link>
|
|
68
78
|
);
|
|
69
79
|
|
|
70
|
-
export const WithIcon = () => (
|
|
71
|
-
<>
|
|
72
|
-
{Object.values(linkTypographies).map((typography) => (
|
|
73
|
-
<Fragment key={typography}>
|
|
74
|
-
{typography}
|
|
75
|
-
<p>
|
|
76
|
-
<Link rightIcon={mdiLink} href="https://www.google.com" typography={typography as any}>
|
|
77
|
-
With right icon
|
|
78
|
-
</Link>
|
|
79
|
-
</p>
|
|
80
|
-
<p>
|
|
81
|
-
<Link leftIcon={mdiChevronDown} href="https://www.google.com" typography={typography as any}>
|
|
82
|
-
With left icon
|
|
83
|
-
</Link>
|
|
84
|
-
</p>
|
|
85
|
-
<p>
|
|
86
|
-
<Link
|
|
87
|
-
leftIcon={mdiChevronDown}
|
|
88
|
-
rightIcon={mdiLink}
|
|
89
|
-
href="https://www.google.com"
|
|
90
|
-
typography={typography as any}
|
|
91
|
-
>
|
|
92
|
-
With right and left icon
|
|
93
|
-
</Link>
|
|
94
|
-
</p>
|
|
95
|
-
</Fragment>
|
|
96
|
-
))}
|
|
97
|
-
</>
|
|
98
|
-
);
|
|
99
|
-
|
|
100
80
|
export const WithCustomizableTypography = () => (
|
|
101
81
|
<>
|
|
102
82
|
<style>{`
|
|
@@ -104,8 +84,58 @@ export const WithCustomizableTypography = () => (
|
|
|
104
84
|
--lumx-typography-custom-title1-font-size: 5px;
|
|
105
85
|
}
|
|
106
86
|
`}</style>
|
|
107
|
-
<Link typography={Typography.custom.title1} href="https://
|
|
87
|
+
<Link typography={Typography.custom.title1} href="https://example.com">
|
|
108
88
|
Link with customizable `body` typography
|
|
109
89
|
</Link>
|
|
110
90
|
</>
|
|
111
91
|
);
|
|
92
|
+
|
|
93
|
+
export const AllTypography = () => {
|
|
94
|
+
const typographies = [undefined, ...Object.values(TypographyInterface), ...Object.values(TypographyCustom)];
|
|
95
|
+
return (
|
|
96
|
+
<table>
|
|
97
|
+
{typographies.map((typography) => (
|
|
98
|
+
<tr key={typography}>
|
|
99
|
+
<td>{typography}</td>
|
|
100
|
+
<td>
|
|
101
|
+
<Link
|
|
102
|
+
leftIcon={mdiChevronDown}
|
|
103
|
+
rightIcon={mdiLink}
|
|
104
|
+
typography={typography}
|
|
105
|
+
href="https://example.com"
|
|
106
|
+
>
|
|
107
|
+
Link text
|
|
108
|
+
</Link>
|
|
109
|
+
</td>
|
|
110
|
+
</tr>
|
|
111
|
+
))}
|
|
112
|
+
</table>
|
|
113
|
+
);
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export const AllColor = () => {
|
|
117
|
+
const colorVariants = [undefined, ...Object.values(ColorVariant)];
|
|
118
|
+
const colors = [undefined, ...Object.values(ColorPalette)];
|
|
119
|
+
return (
|
|
120
|
+
<table style={{ borderCollapse: 'separate', borderSpacing: 5 }}>
|
|
121
|
+
<tr>
|
|
122
|
+
<td />
|
|
123
|
+
{colorVariants.map((colorVariant) => (
|
|
124
|
+
<td key={colorVariant}>{colorVariant}</td>
|
|
125
|
+
))}
|
|
126
|
+
</tr>
|
|
127
|
+
{colors.map((color) => (
|
|
128
|
+
<tr key={color}>
|
|
129
|
+
<td>{color}</td>
|
|
130
|
+
{colorVariants.map((colorVariant) => (
|
|
131
|
+
<td key={colorVariant}>
|
|
132
|
+
<Link href="https://example.com" color={color} colorVariant={colorVariant}>
|
|
133
|
+
Some text
|
|
134
|
+
</Link>
|
|
135
|
+
</td>
|
|
136
|
+
))}
|
|
137
|
+
</tr>
|
|
138
|
+
))}
|
|
139
|
+
</table>
|
|
140
|
+
);
|
|
141
|
+
};
|
|
@@ -4,7 +4,7 @@ import isEmpty from 'lodash/isEmpty';
|
|
|
4
4
|
|
|
5
5
|
import classNames from 'classnames';
|
|
6
6
|
|
|
7
|
-
import { Color, ColorVariant, Icon, Size, Typography
|
|
7
|
+
import { Color, ColorVariant, Icon, Size, Typography } from '@lumx/react';
|
|
8
8
|
import { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';
|
|
9
9
|
import { renderLink } from '@lumx/react/utils/renderLink';
|
|
10
10
|
|
|
@@ -31,7 +31,7 @@ export interface LinkProps extends GenericProps {
|
|
|
31
31
|
/** Link target. */
|
|
32
32
|
target?: HTMLAnchorProps['target'];
|
|
33
33
|
/** Typography variant. */
|
|
34
|
-
typography?:
|
|
34
|
+
typography?: Typography;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
/**
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { shiftPosition } from './useFocusPointStyle';
|
|
2
|
+
|
|
3
|
+
describe('shiftPosition', () => {
|
|
4
|
+
it('should always return 0% if the imageSize fits the containerSize', () => {
|
|
5
|
+
expect(
|
|
6
|
+
shiftPosition({
|
|
7
|
+
scale: 1.5,
|
|
8
|
+
focusPoint: 0,
|
|
9
|
+
imageSize: 1000,
|
|
10
|
+
containerSize: 1000,
|
|
11
|
+
}),
|
|
12
|
+
).toEqual(0);
|
|
13
|
+
expect(
|
|
14
|
+
shiftPosition({
|
|
15
|
+
scale: 1,
|
|
16
|
+
focusPoint: 0.27,
|
|
17
|
+
imageSize: 1000,
|
|
18
|
+
containerSize: 1000,
|
|
19
|
+
}),
|
|
20
|
+
).toEqual(0);
|
|
21
|
+
expect(
|
|
22
|
+
shiftPosition({
|
|
23
|
+
scale: 3,
|
|
24
|
+
focusPoint: 0.5,
|
|
25
|
+
imageSize: 1000,
|
|
26
|
+
containerSize: 1000,
|
|
27
|
+
}),
|
|
28
|
+
).toEqual(0);
|
|
29
|
+
expect(
|
|
30
|
+
shiftPosition({
|
|
31
|
+
scale: 2.4,
|
|
32
|
+
focusPoint: 1,
|
|
33
|
+
imageSize: 1000,
|
|
34
|
+
containerSize: 1000,
|
|
35
|
+
}),
|
|
36
|
+
).toEqual(0);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
describe('with bigger side than container ', () => {
|
|
40
|
+
// This use case will come, for example, if you have an image in width 100%
|
|
41
|
+
// but the image after being resized to keep the ratio is higher than the container.
|
|
42
|
+
// Then we are calculating the y shift.
|
|
43
|
+
|
|
44
|
+
const image = { width: 1000, height: 1200 };
|
|
45
|
+
const container = { width: 1000, height: 300 };
|
|
46
|
+
// scale is always the minimum scale ratio. Here imagewidth/containerwidth.
|
|
47
|
+
const scale = image.width / container.width; // 1
|
|
48
|
+
it('should return 0% if focusPoint equals 0', () => {
|
|
49
|
+
expect(
|
|
50
|
+
shiftPosition({
|
|
51
|
+
scale,
|
|
52
|
+
focusPoint: 0,
|
|
53
|
+
imageSize: image.height,
|
|
54
|
+
containerSize: container.height,
|
|
55
|
+
}),
|
|
56
|
+
).toEqual(0);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('should return 100% if focusPoint equals 1', () => {
|
|
60
|
+
expect(
|
|
61
|
+
shiftPosition({
|
|
62
|
+
scale,
|
|
63
|
+
focusPoint: 1,
|
|
64
|
+
imageSize: image.height,
|
|
65
|
+
containerSize: container.height,
|
|
66
|
+
}),
|
|
67
|
+
).toEqual(100);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('should return 50% if focusPoint equals 0.5', () => {
|
|
71
|
+
expect(
|
|
72
|
+
shiftPosition({
|
|
73
|
+
scale,
|
|
74
|
+
focusPoint: 0.5,
|
|
75
|
+
imageSize: image.height,
|
|
76
|
+
containerSize: container.height,
|
|
77
|
+
}),
|
|
78
|
+
).toEqual(50);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('should return 16% if focusPoint equals 0.25', () => {
|
|
82
|
+
expect(
|
|
83
|
+
shiftPosition({
|
|
84
|
+
scale,
|
|
85
|
+
focusPoint: 0.25,
|
|
86
|
+
imageSize: image.height,
|
|
87
|
+
containerSize: container.height,
|
|
88
|
+
}),
|
|
89
|
+
).toEqual(16);
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
});
|
|
@@ -3,11 +3,24 @@ import { AspectRatio } from '@lumx/react/components';
|
|
|
3
3
|
import { ThumbnailProps } from '@lumx/react/components/thumbnail/Thumbnail';
|
|
4
4
|
|
|
5
5
|
// Calculate shift to center the focus point in the container.
|
|
6
|
-
function shiftPosition(
|
|
6
|
+
export function shiftPosition({
|
|
7
|
+
scale,
|
|
8
|
+
focusPoint,
|
|
9
|
+
imageSize,
|
|
10
|
+
containerSize,
|
|
11
|
+
}: {
|
|
12
|
+
scale: number;
|
|
13
|
+
focusPoint: number;
|
|
14
|
+
imageSize: number;
|
|
15
|
+
containerSize: number;
|
|
16
|
+
}) {
|
|
17
|
+
if (imageSize === containerSize) return 0;
|
|
7
18
|
const scaledSize = imageSize / scale;
|
|
19
|
+
|
|
8
20
|
const scaledFocusHeight = focusPoint * scaledSize;
|
|
9
21
|
const startFocus = scaledFocusHeight - containerSize / 2;
|
|
10
22
|
const shift = startFocus / (scaledSize - containerSize);
|
|
23
|
+
|
|
11
24
|
return Math.floor(Math.max(Math.min(shift, 1), 0) * 100);
|
|
12
25
|
}
|
|
13
26
|
|
|
@@ -73,14 +86,23 @@ export const useFocusPointStyle = (
|
|
|
73
86
|
|
|
74
87
|
// Focus Y relative to the top (instead of the center)
|
|
75
88
|
const focusPointFromTop = Math.abs((focusPoint?.y || 0) - 1) / 2;
|
|
76
|
-
const y = shiftPosition(
|
|
89
|
+
const y = shiftPosition({
|
|
90
|
+
scale,
|
|
91
|
+
focusPoint: focusPointFromTop,
|
|
92
|
+
imageSize: imageSize.height,
|
|
93
|
+
containerSize: containerSize.height,
|
|
94
|
+
});
|
|
77
95
|
|
|
78
96
|
// Focus X relative to the left (instead of the center)
|
|
79
97
|
const focusPointFromLeft = Math.abs((focusPoint?.x || 0) + 1) / 2;
|
|
80
|
-
const x = shiftPosition(
|
|
98
|
+
const x = shiftPosition({
|
|
99
|
+
scale,
|
|
100
|
+
focusPoint: focusPointFromLeft,
|
|
101
|
+
imageSize: imageSize.width,
|
|
102
|
+
containerSize: containerSize.width,
|
|
103
|
+
});
|
|
81
104
|
|
|
82
105
|
const objectPosition = `${x}% ${y}%`;
|
|
83
|
-
|
|
84
106
|
// Update only if needed.
|
|
85
107
|
setStyle((oldStyle) => (oldStyle.objectPosition === objectPosition ? oldStyle : { objectPosition }));
|
|
86
108
|
}, [aspectRatio, containerSize, element, focusPoint?.x, focusPoint?.y, image, imageSize]);
|
package/types.d.ts
CHANGED
|
@@ -162,13 +162,16 @@ export declare const TypographyTitleCustom: {
|
|
|
162
162
|
readonly title6: "custom-title6";
|
|
163
163
|
};
|
|
164
164
|
export declare type TypographyTitleCustom = ValueOf<typeof TypographyTitleCustom>;
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
readonly
|
|
170
|
-
readonly "
|
|
171
|
-
readonly
|
|
165
|
+
/**
|
|
166
|
+
* List of typographies that can be customized (via CSS variables).
|
|
167
|
+
*/
|
|
168
|
+
export declare const TypographyCustom: {
|
|
169
|
+
readonly intro: "custom-intro";
|
|
170
|
+
readonly "body-large": "custom-body-large";
|
|
171
|
+
readonly body: "custom-body";
|
|
172
|
+
readonly quote: "custom-quote";
|
|
173
|
+
readonly "publish-info": "custom-publish-info";
|
|
174
|
+
readonly button: "custom-button";
|
|
172
175
|
readonly title1: "custom-title1";
|
|
173
176
|
readonly title2: "custom-title2";
|
|
174
177
|
readonly title3: "custom-title3";
|
|
@@ -182,12 +185,12 @@ export declare type TypographyCustom = ValueOf<typeof TypographyCustom>;
|
|
|
182
185
|
*/
|
|
183
186
|
export declare const Typography: {
|
|
184
187
|
readonly custom: {
|
|
185
|
-
readonly intro: "intro";
|
|
186
|
-
readonly "body-large": "body-large";
|
|
187
|
-
readonly body: "body";
|
|
188
|
-
readonly quote: "quote";
|
|
189
|
-
readonly "publish-info": "publish-info";
|
|
190
|
-
readonly button: "button";
|
|
188
|
+
readonly intro: "custom-intro";
|
|
189
|
+
readonly "body-large": "custom-body-large";
|
|
190
|
+
readonly body: "custom-body";
|
|
191
|
+
readonly quote: "custom-quote";
|
|
192
|
+
readonly "publish-info": "custom-publish-info";
|
|
193
|
+
readonly button: "custom-button";
|
|
191
194
|
readonly title1: "custom-title1";
|
|
192
195
|
readonly title2: "custom-title2";
|
|
193
196
|
readonly title3: "custom-title3";
|
|
@@ -1471,7 +1474,7 @@ export interface LinkProps extends GenericProps {
|
|
|
1471
1474
|
/** Link target. */
|
|
1472
1475
|
target?: HTMLAnchorProps["target"];
|
|
1473
1476
|
/** Typography variant. */
|
|
1474
|
-
typography?:
|
|
1477
|
+
typography?: Typography;
|
|
1475
1478
|
}
|
|
1476
1479
|
/**
|
|
1477
1480
|
* Link component.
|