Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/npm_and_yarn/stylelint-16.8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
drl990114 authored Nov 8, 2024
2 parents fc96f2f + 1a488be commit 74305fb
Show file tree
Hide file tree
Showing 24 changed files with 5,185 additions and 4,636 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Install node
uses: actions/setup-node@v4
with:
node-version: '20'

- uses: actions/checkout@v2
- name: Install dependencies
run: yarn install --immutable
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/test-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Install node
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Checkout repository
uses: actions/checkout@v3 # v3

Expand Down
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20
17 changes: 14 additions & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
const gulp = require('gulp');
const babel = require('gulp-babel');
const less = require('gulp-less');
const autoprefixer = require('gulp-autoprefixer');
const cssnano = require('gulp-cssnano');
const through2 = require('through2');

Expand Down Expand Up @@ -38,7 +37,20 @@ function compileScripts(babelEnv, destDir) {
process.env.BABEL_ENV = babelEnv;
return gulp
.src(scripts)
.pipe(babel()) // 使用gulp-babel处理
.pipe(
babel({
plugins: [
[
require.resolve('babel-plugin-module-resolver'),
{
alias: {
'@': './src',
},
},
],
],
}),
) // 使用gulp-babel处理
.pipe(
through2.obj(function z(file, encoding, next) {
this.push(file.clone());
Expand Down Expand Up @@ -89,7 +101,6 @@ function less2css() {
return gulp
.src(paths.styles)
.pipe(less()) // 处理less文件
.pipe(autoprefixer()) // 根据browserslistrc增加前缀
.pipe(cssnano({ zindex: false, reduceIdents: false })) // 压缩
.pipe(gulp.dest(paths.dest.lib))
.pipe(gulp.dest(paths.dest.esm));
Expand Down
147 changes: 72 additions & 75 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zens",
"version": "0.0.32",
"version": "0.0.39",
"description": "MarkFlowy's ui component library.",
"keywords": [],
"homepage": "https://github.com/drl990114/zens#readme",
Expand Down Expand Up @@ -58,98 +58,95 @@
}
},
"dependencies": {
"@ant-design/icons": "^5.3.7",
"@ariakit/react": "^0.4.5",
"@ant-design/icons": "^5.5.1",
"@ariakit/react": "^0.4.13",
"@babel/runtime": "^7",
"@emotion/is-prop-valid": "^1.2.2",
"@floating-ui/dom": "^1.0.0",
"@types/lodash": "^4.17.6",
"classnames": "^2.3.0",
"clsx": "^2.0.0",
"@emotion/is-prop-valid": "^1.3.1",
"@floating-ui/dom": "^1.6.12",
"@types/lodash": "^4.17.13",
"classnames": "^2.5.1",
"clsx": "^2.1.1",
"color": "^4.2.3",
"lodash": "^4.17.21",
"rc-image": "^7.5.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-spinners": "^0.13.8",
"sonner": "^1.4.0",
"styled-components": "^6.1.11",
"stylis": "^4.0.0"
"rc-image": "^7.11.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-spinners": "^0.14.1",
"sonner": "^1.7.0",
"styled-components": "^6.1.13",
"stylis": "^4.3.4"
},
"devDependencies": {
"@babel/core": "^7.7.7",
"@babel/plugin-transform-react-jsx": "^7.23.4",
"@babel/plugin-transform-runtime": "^7.7.6",
"@babel/preset-env": "^7.7.7",
"@babel/preset-react": "^7.7.4",
"@babel/preset-typescript": "^7.7.7",
"@commitlint/cli": "^19.2.2",
"@commitlint/config-conventional": "^19.2.2",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "12.1.5",
"@testing-library/user-event": "^14.4.3",
"@babel/core": "^7.26.0",
"@babel/plugin-transform-react-jsx": "^7.25.9",
"@babel/plugin-transform-runtime": "^7.25.9",
"@babel/preset-env": "^7.26.0",
"@babel/preset-react": "^7.25.9",
"@babel/preset-typescript": "^7.26.0",
"@commitlint/cli": "^19.5.0",
"@commitlint/config-conventional": "^19.5.0",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "16.0.1",
"@testing-library/user-event": "^14.5.2",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@types/color": "^3.0.6",
"@types/css": "^0.0.33",
"@types/css-modules": "^1.0.2",
"@types/jest": "29.4.0",
"@types/node": "^20.12.7",
"@types/react": "^18.2.17",
"@types/react-dom": "18.0.11",
"@types/react-test-renderer": "^18.0.0",
"@typescript-eslint/eslint-plugin": "5.54.0",
"@typescript-eslint/parser": "5.62.0",
"@umijs/fabric": "^3",
"babel-plugin-import": "^1.13.3",
"commitizen": "^4.2.5",
"core-js": "^3.26.1",
"@types/color": "^4.2.0",
"@types/css": "^0.0.38",
"@types/css-modules": "^1.0.5",
"@types/jest": "29.5.14",
"@types/node": "^22.8.7",
"@types/react": "^18.3.12",
"@types/react-dom": "18.3.1",
"@types/react-test-renderer": "^18.3.0",
"@typescript-eslint/eslint-plugin": "8.12.2",
"@typescript-eslint/parser": "8.12.2",
"@umijs/fabric": "^4",
"babel-plugin-import": "^1.13.8",
"babel-plugin-module-resolver": "^5.0.2",
"commitizen": "^4.3.1",
"core-js": "^3.39.0",
"cpr": "^3.0.1",
"cross-env": "^7.0.3",
"css-loader": "6.10.0",
"css-loader": "7.1.2",
"cz-conventional-changelog": "^3.3.0",
"doctoc": "^1.4.0",
"dumi": "^2.2.4",
"esbuild": "0.20.2",
"esbuild-css-modules-plugin": "^2.7.1",
"eslint": "8.57.0",
"doctoc": "^2.2.1",
"dumi": "^2.4.13",
"esbuild": "0.24.0",
"esbuild-css-modules-plugin": "^3.1.2",
"eslint": "9.14.0",
"eslint-config-airbnb": "19.0.4",
"eslint-config-prettier": "8.6.0",
"eslint-plugin-import": "2.27.5",
"eslint-plugin-jsx-a11y": "6.7.1",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react": "7.32.2",
"eslint-plugin-react-hooks": "^4.2.0",
"gh-pages": "^3.2.3",
"gulp": "^4.0.2",
"gulp-autoprefixer": "^7.0.1",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-import": "2.31.0",
"eslint-plugin-jsx-a11y": "6.10.2",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-react": "7.37.2",
"eslint-plugin-react-hooks": "^5.0.0",
"gh-pages": "^6.2.0",
"gulp": "^5.0.0",
"gulp-babel": "^8.0.0",
"gulp-cssnano": "^2.1.3",
"gulp-less": "^5.0.0",
"identity-obj-proxy": "^3.0.0",
"jest": "29.4.3",
"jest-environment-jsdom": "29.4.3",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"jest-transform-css": "6.0.1",
"less": "^3.10.3",
"lint-staged": "15.2.2",
"np": "^10.0.2",
"less": "^4.2.0",
"lint-staged": "15.2.10",
"np": "^10.0.7",
"plop": "^4",
"postcss": "8.4.21",
"prettier": "3.2.5",
"prettier-plugin-packagejson": "^2.3.0",
"postcss": "8.4.47",
"prettier": "3.3.3",
"prettier-plugin-packagejson": "^2.5.3",
"process": "^0.11.10",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-spinners": "^0.13.8",
"rimraf": "^3.0.2",
"rimraf": "^6.0.1",
"snapshot-diff": "^0.10.0",
"style-loader": "^3.3.0",
"stylelint": "^16.3.1",
"stylelint-config-prettier": "^8.0.2",
"stylelint-config-standard": "^36.0.0",
"through2": "^3.0.1",
"ts-jest": "29.0.5",
"ts-node": "^10.9.1",
"typescript": "^5.3.3"
"style-loader": "^4.0.0",
"stylelint": "^16.10.0",
"stylelint-config-prettier": "^9.0.5",
"stylelint-config-standard": "^36.0.1",
"through2": "^4.0.2",
"ts-jest": "29.2.5",
"ts-node": "^10.9.2",
"typescript": "^5.6.3"
},
"publishConfig": {
"access": "public",
Expand Down
5 changes: 3 additions & 2 deletions src/Box/index.tsx
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} />
})
)
1 change: 0 additions & 1 deletion src/Icons/index.tsx

This file was deleted.

70 changes: 70 additions & 0 deletions src/Image/ErrorTip.tsx
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;
61 changes: 61 additions & 0 deletions src/Image/Img.tsx
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);
Loading

0 comments on commit 74305fb

Please sign in to comment.