forstok-ui-lib 5.0.2 → 5.0.3
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/dist/index.d.ts +7 -2
- package/dist/index.js +48 -41
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +46 -39
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/assets/images/image-placeholder.jpg +0 -0
- package/src/components/image/index.tsx +17 -0
- package/src/components/image/styles.ts +39 -0
- package/src/components/index.ts +1 -0
- package/tsconfig.json +1 -2
package/package.json
CHANGED
|
Binary file
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ImgHTMLAttributes, ReactEventHandler } from 'react';
|
|
2
|
+
import ImagePlaceholder from '../../assets/images/image-placeholder.jpg';
|
|
3
|
+
import { ImageContainer } from './styles';
|
|
4
|
+
|
|
5
|
+
type TImage = ImgHTMLAttributes<HTMLImageElement> & {
|
|
6
|
+
$mode?: string
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const ImageComponent = ({ $mode, ...props }: TImage) => {
|
|
10
|
+
const { width, height } = props;
|
|
11
|
+
const evError: ReactEventHandler<HTMLImageElement> = e => {
|
|
12
|
+
(e.target as HTMLImageElement).src = ImagePlaceholder;
|
|
13
|
+
}
|
|
14
|
+
return <ImageContainer $mode={$mode} width={width} height={height} onError={evError} {...props} />;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default ImageComponent;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import styled, { css } from 'styled-components'
|
|
2
|
+
|
|
3
|
+
const storeStyles = css `
|
|
4
|
+
width: 32px;
|
|
5
|
+
height: 32px;
|
|
6
|
+
`
|
|
7
|
+
const productStyles = css`
|
|
8
|
+
background-color: var(--mt-clr-bg);
|
|
9
|
+
`
|
|
10
|
+
|
|
11
|
+
const getImageModifiedStyled = ({ $mode, width, height }: { $mode?: string, width?: string|number, height?: string|number }) => {
|
|
12
|
+
let style = ''
|
|
13
|
+
if ($mode === 'store') {
|
|
14
|
+
style += storeStyles
|
|
15
|
+
} else if ($mode === 'product') {
|
|
16
|
+
style += productStyles
|
|
17
|
+
}
|
|
18
|
+
if (width && height) {
|
|
19
|
+
style += `
|
|
20
|
+
width:${width};
|
|
21
|
+
height:${height};
|
|
22
|
+
`
|
|
23
|
+
} else if (width) {
|
|
24
|
+
style += `
|
|
25
|
+
width:${width};
|
|
26
|
+
height:${width};
|
|
27
|
+
`
|
|
28
|
+
} else if (height) {
|
|
29
|
+
style += `
|
|
30
|
+
width:${width};
|
|
31
|
+
height:${height};
|
|
32
|
+
`
|
|
33
|
+
}
|
|
34
|
+
return style
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const ImageContainer = styled.img<{ $mode?: string, width?: string|number, height?: string|number }>`
|
|
38
|
+
${getImageModifiedStyled}
|
|
39
|
+
`
|
package/src/components/index.ts
CHANGED
|
@@ -11,6 +11,7 @@ export { default as MessageComponent } from './message';
|
|
|
11
11
|
export { default as MessageQuestionComponent } from './message/question';
|
|
12
12
|
export { default as PopupComponent } from './popup';
|
|
13
13
|
export { default as ReactPortalComponent } from './portal';
|
|
14
|
+
export { default as ImageComponent } from './image';
|
|
14
15
|
|
|
15
16
|
export * from './dropdown/typed';
|
|
16
17
|
export * from './message/typed';
|