-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into dependabot/npm_and_yarn/stylelint-16.8.1
- Loading branch information
Showing
24 changed files
with
5,185 additions
and
4,636 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
import React, { forwardRef } from 'react' | ||
import React, { forwardRef, memo } from 'react' | ||
|
||
export interface BoxProps extends BaseComponentProps { | ||
ref?: React.Ref<any> | ||
} | ||
|
||
export const Box = forwardRef<{}, BoxProps>((props, ref) => { | ||
export const Box = memo(forwardRef<HTMLDivElement, BoxProps>((props, ref) => { | ||
return <div ref={ref} {...props} /> | ||
}) | ||
) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import styled from 'styled-components'; | ||
|
||
const ErrorTipContainer = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
color: ${props => props.theme.errorTipColor}; | ||
.zens-error-icon-box { | ||
width: 40px; | ||
height: 40px; | ||
} | ||
.zens-error-icon { | ||
width: 100%; | ||
height: 100%; | ||
} | ||
.zens-error-text { | ||
font-size: 12px; | ||
line-height: 1.6667; | ||
text-align: center; | ||
padding: 8px 16px; | ||
} | ||
`; | ||
|
||
export interface ErrorTipProps { | ||
errortip: string; | ||
height?: number; | ||
width?: number; | ||
} | ||
export const ErrorTip = (props: ErrorTipProps) => { | ||
const { errortip, width = 100, height = 70 } = props; | ||
|
||
return ( | ||
<ErrorTipContainer style={{ width: `${width}px`, height: `${height}px` }}> | ||
<div className="zens-error-icon-box"> | ||
<svg | ||
fill="none" | ||
stroke="currentColor" | ||
strokeWidth="4" | ||
viewBox="0 0 48 48" | ||
aria-hidden="true" | ||
focusable="false" | ||
className="zens-error-icon" | ||
> | ||
<path d="M41 26V9a2 2 0 0 0-2-2H9a2 2 0 0 0-2 2v30a2 2 0 0 0 2 2h17"></path> | ||
<path d="m24 33 9-8.5V27s-2 1-3.5 2.5C27.841 31.159 27 33 27 33h-3Zm0 0-3.5-4.5L17 33h7Z"></path> | ||
<path | ||
fill="currentColor" | ||
stroke="none" | ||
d="M20.5 28.5 17 33h7l-3.5-4.5ZM33 24.5 24 33h3s.841-1.841 2.5-3.5C31 28 33 27 33 27v-2.5Z" | ||
></path> | ||
<path | ||
fill="currentColor" | ||
fillRule="evenodd" | ||
stroke="none" | ||
d="M46 38a8 8 0 1 1-16 0 8 8 0 0 1 16 0Zm-4.95-4.782 1.74 1.74-3.045 3.046 3.046 3.046-1.74 1.74-3.047-3.045-3.046 3.046-1.74-1.74 3.046-3.047-3.046-3.046 1.74-1.74 3.046 3.046 3.046-3.046Z" | ||
clipRule="evenodd" | ||
></path> | ||
<path d="M17 15h-2v2h2v-2Z"></path> | ||
</svg> | ||
</div> | ||
|
||
<span className="zens-error-text">{errortip}</span> | ||
</ErrorTipContainer> | ||
); | ||
}; | ||
export default ErrorTip; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// @ts-nocheck | ||
import React, { forwardRef } from 'react'; | ||
|
||
import imagePromiseFactory from './imagePromiseFactory'; | ||
import useImage, { useImageProps } from './use-image'; | ||
|
||
export type ImgProps = Omit< | ||
React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement>, | ||
'src' | ||
> & | ||
Omit<useImageProps, 'srcList'> & { | ||
src: useImageProps['srcList']; // same types, different name | ||
loader?: JSX.Element | null; | ||
unloader?: JSX.Element | null; | ||
decode?: boolean; | ||
crossorigin?: string; | ||
container?: (children: React.ReactNode) => JSX.Element; | ||
loaderContainer?: (children: React.ReactNode) => JSX.Element; | ||
unloaderContainer?: (children: React.ReactNode) => JSX.Element; | ||
}; | ||
|
||
const passthroughContainer = (x) => x; | ||
|
||
function Img( | ||
{ | ||
decode = true, | ||
src: srcList = [], | ||
loader = null, | ||
unloader = null, | ||
container = passthroughContainer, | ||
loaderContainer = passthroughContainer, | ||
unloaderContainer = passthroughContainer, | ||
imgPromise, | ||
crossorigin, | ||
useSuspense = false, | ||
...imgProps // anything else will be passed to the <img> element | ||
}: ImgProps, | ||
ref, | ||
): JSX.Element | null { | ||
imgPromise = imgPromise || imagePromiseFactory({ decode, crossOrigin: crossorigin }); | ||
const { src, isLoading } = useImage({ | ||
srcList, | ||
imgPromise, | ||
useSuspense, | ||
}); | ||
|
||
// console.log({src, isLoading, resolvedSrc, useSuspense}) | ||
|
||
// show img if loaded | ||
if (src) return container(<img src={src} {...imgProps} ref={ref} />); | ||
|
||
// show loader if we have one and were still trying to load image | ||
if (!useSuspense && isLoading) return loaderContainer(loader); | ||
|
||
// show unloader if we have one and we have no more work to do | ||
if (!useSuspense && unloader) return unloaderContainer(unloader); | ||
|
||
return null; | ||
} | ||
|
||
export default forwardRef<HTMLImageElement, ImgProps>(Img); |
Oops, something went wrong.