MadCcc
2 years ago
33 changed files with 365 additions and 435 deletions
@ -0,0 +1,38 @@ |
|||
# Use the latest 2.1 version of CircleCI pipeline process engine. |
|||
# See: https://circleci.com/docs/2.0/configuration-reference |
|||
version: 2.1 |
|||
|
|||
# Define a job to be invoked later in a workflow. |
|||
# See: https://circleci.com/docs/2.0/configuration-reference/#jobs |
|||
jobs: |
|||
test-argos-ci: |
|||
docker: |
|||
- image: circleci/node:16-browsers |
|||
steps: |
|||
- checkout |
|||
- run: |
|||
name: Install node_modules |
|||
command: npm i |
|||
- run: |
|||
name: Install argos cli |
|||
command: npm i fast-glob lodash @argos-ci/core |
|||
- run: |
|||
name: Install puppeteer |
|||
command: node node_modules/puppeteer/install.js |
|||
- run: |
|||
name: Build dist file |
|||
command: npm run dist |
|||
- run: |
|||
name: Run image screenshot tests |
|||
command: npm run test-image |
|||
- run: |
|||
name: Upload screenshots to Argos CI |
|||
command: npm run argos |
|||
|
|||
|
|||
# Invoke jobs via workflows |
|||
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows |
|||
workflows: |
|||
test-argos-ci-workflow: |
|||
jobs: |
|||
- test-argos-ci |
@ -1,63 +0,0 @@ |
|||
# Upload 📷 UI snapshots to argos server, help visual regression testing. |
|||
name: 📷 UI Upload |
|||
|
|||
on: |
|||
workflow_run: |
|||
workflows: ["📷 UI"] |
|||
types: |
|||
- completed |
|||
|
|||
permissions: |
|||
contents: read |
|||
|
|||
jobs: |
|||
upload-ui: |
|||
permissions: |
|||
actions: read # for dawidd6/action-download-artifact to query and download artifacts |
|||
pull-requests: read # for dawidd6/action-download-artifact to query commit hash |
|||
name: deploy preview |
|||
runs-on: ubuntu-latest |
|||
if: > |
|||
github.repository == 'ant-design/ant-design' && |
|||
github.event.workflow_run.conclusion == 'success' |
|||
steps: |
|||
- name: checkout |
|||
uses: actions/checkout@v3 |
|||
|
|||
- name: Download commit artifact |
|||
uses: dawidd6/action-download-artifact@v2.23.0 |
|||
with: |
|||
workflow: ${{ github.event.workflow_run.workflow_id }} |
|||
name: commit |
|||
|
|||
- name: Save commit id |
|||
id: commit |
|||
run: echo "::set-output name=id::$(<commit.txt)" |
|||
|
|||
- name: Download branch artifact |
|||
uses: dawidd6/action-download-artifact@v2.23.0 |
|||
with: |
|||
workflow: ${{ github.event.workflow_run.workflow_id }} |
|||
name: branch |
|||
|
|||
- name: Save branch id |
|||
id: branch |
|||
run: echo "::set-output name=id::$(<branch.txt)" |
|||
|
|||
- name: Download snapshots artifact |
|||
uses: dawidd6/action-download-artifact@v2.23.0 |
|||
with: |
|||
workflow: ${{ github.event.workflow_run.workflow_id }} |
|||
workflow_conclusion: success |
|||
name: snapshots |
|||
path: imageSnapshots |
|||
|
|||
- name: Install |
|||
run: npm i fast-glob lodash @argos-ci/core |
|||
|
|||
- name: Upload on Argos |
|||
id: deploy |
|||
run: npm run argos |
|||
env: |
|||
ARGOS_TOKEN: ${{ secrets.ARGOS_TOKEN }} |
|||
ARGOS_PARALLEL_NONCE: ${{ github.run_id }} |
@ -1,93 +0,0 @@ |
|||
name: 📷 UI |
|||
|
|||
on: |
|||
pull_request: |
|||
types: [opened, synchronize, reopened] |
|||
push: |
|||
|
|||
# Cancel prev CI if new commit come |
|||
concurrency: |
|||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
|||
cancel-in-progress: true |
|||
|
|||
permissions: |
|||
contents: read |
|||
|
|||
jobs: |
|||
imagesnapshot: |
|||
runs-on: ubuntu-latest |
|||
steps: |
|||
- name: checkout |
|||
uses: actions/checkout@v3 |
|||
with: |
|||
fetch-depth: 2 |
|||
|
|||
- name: cache package-lock.json |
|||
uses: actions/cache@v3 |
|||
with: |
|||
path: package-temp-dir |
|||
key: lock-${{ github.sha }} |
|||
|
|||
- uses: actions/setup-node@v3 |
|||
with: |
|||
node-version: '16' |
|||
|
|||
- name: create package-lock.json |
|||
run: npm i --package-lock-only --ignore-scripts |
|||
|
|||
- name: hack for single file |
|||
run: | |
|||
if [ ! -d "package-temp-dir" ]; then |
|||
mkdir package-temp-dir |
|||
fi |
|||
cp package-lock.json package-temp-dir |
|||
- name: cache node_modules |
|||
id: node_modules_cache_id |
|||
uses: actions/cache@v3 |
|||
with: |
|||
path: node_modules |
|||
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }} |
|||
|
|||
- name: install |
|||
if: steps.node_modules_cache_id.outputs.cache-hit != 'true' |
|||
run: npm ci |
|||
|
|||
- name: test |
|||
run: npm run test-image |
|||
|
|||
- name: upload snapshots artifact |
|||
uses: actions/upload-artifact@v3 |
|||
with: |
|||
name: snapshots |
|||
path: imageSnapshots/ |
|||
retention-days: 3 |
|||
|
|||
- name: Save commit |
|||
if: github.event_name == 'pull_request' && github.base_ref == 'master' |
|||
run: echo ${{ github.event.pull_request.head.sha }} > ./commit.txt |
|||
|
|||
- name: Save commit |
|||
if: github.event_name == 'push' |
|||
run: echo ${{ github.sha }} > ./commit.txt |
|||
|
|||
- name: Upload commit |
|||
if: ${{ always() }} |
|||
uses: actions/upload-artifact@v3 |
|||
with: |
|||
name: commit |
|||
path: ./commit.txt |
|||
|
|||
- name: Save branch |
|||
if: github.event_name == 'pull_request' && github.base_ref == 'master' |
|||
run: echo pull/${{ github.event.pull_request.number }}/merge > ./branch.txt |
|||
|
|||
- name: Save branch |
|||
if: github.event_name == 'push' |
|||
run: echo ${GITHUB_REF##*/} > ./branch.txt |
|||
|
|||
- name: Upload branch |
|||
if: ${{ always() }} |
|||
uses: actions/upload-artifact@v3 |
|||
with: |
|||
name: branch |
|||
path: ./branch.txt |
@ -1,6 +0,0 @@ |
|||
FROM buildkite/puppeteer:10.0.0 |
|||
RUN mkdir /app |
|||
WORKDIR /app |
|||
COPY package.json ./ |
|||
ENV PATH="${PATH}:/app/node_modules/.bin" |
|||
COPY . . |
@ -1,6 +1,6 @@ |
|||
import * as React from 'react'; |
|||
import type { AntAnchor } from './Anchor'; |
|||
|
|||
const AnchorContext = React.createContext<AntAnchor>(null as any); |
|||
const AnchorContext = React.createContext<AntAnchor | undefined>(undefined); |
|||
|
|||
export default AnchorContext; |
|||
|
@ -1,72 +1,82 @@ |
|||
import classNames from 'classnames'; |
|||
import { composeRef } from 'rc-util/lib/ref'; |
|||
import * as React from 'react'; |
|||
import type { DirectionType } from '../config-provider'; |
|||
import { ConfigContext } from '../config-provider'; |
|||
import warning from '../_util/warning'; |
|||
import useStyle from './style'; |
|||
|
|||
export interface TypographyProps { |
|||
export interface TypographyProps<C extends keyof JSX.IntrinsicElements> |
|||
extends React.HTMLAttributes<HTMLElement> { |
|||
id?: string; |
|||
prefixCls?: string; |
|||
className?: string; |
|||
style?: React.CSSProperties; |
|||
children?: React.ReactNode; |
|||
/** @internal */ |
|||
component?: C; |
|||
['aria-label']?: string; |
|||
direction?: DirectionType; |
|||
} |
|||
|
|||
interface InternalTypographyProps extends TypographyProps { |
|||
component?: string; |
|||
interface InternalTypographyProps<C extends keyof JSX.IntrinsicElements> |
|||
extends TypographyProps<C> { |
|||
/** @deprecated Use `ref` directly if using React 16 */ |
|||
setContentRef?: (node: HTMLElement) => void; |
|||
} |
|||
|
|||
const Typography: React.ForwardRefRenderFunction<{}, InternalTypographyProps> = ( |
|||
{ |
|||
prefixCls: customizePrefixCls, |
|||
component = 'article', |
|||
className, |
|||
'aria-label': ariaLabel, |
|||
setContentRef, |
|||
children, |
|||
...restProps |
|||
}, |
|||
ref, |
|||
) => { |
|||
const { getPrefixCls, direction } = React.useContext(ConfigContext); |
|||
const Typography = React.forwardRef< |
|||
HTMLElement, |
|||
InternalTypographyProps<keyof JSX.IntrinsicElements> |
|||
>( |
|||
( |
|||
{ |
|||
prefixCls: customizePrefixCls, |
|||
component: Component = 'article', |
|||
className, |
|||
setContentRef, |
|||
children, |
|||
direction: typographyDirection, |
|||
...restProps |
|||
}, |
|||
ref, |
|||
) => { |
|||
const { getPrefixCls, direction: contextDirection } = React.useContext(ConfigContext); |
|||
|
|||
let mergedRef = ref; |
|||
if (setContentRef) { |
|||
warning(false, 'Typography', '`setContentRef` is deprecated. Please use `ref` instead.'); |
|||
mergedRef = composeRef(ref, setContentRef); |
|||
} |
|||
const direction = typographyDirection ?? contextDirection; |
|||
|
|||
const Component = component as any; |
|||
const prefixCls = getPrefixCls('typography', customizePrefixCls); |
|||
let mergedRef = ref; |
|||
if (setContentRef) { |
|||
warning(false, 'Typography', '`setContentRef` is deprecated. Please use `ref` instead.'); |
|||
mergedRef = composeRef(ref, setContentRef); |
|||
} |
|||
|
|||
// Style
|
|||
const [wrapSSR, hashId] = useStyle(prefixCls); |
|||
const prefixCls = getPrefixCls('typography', customizePrefixCls); |
|||
|
|||
const componentClassName = classNames( |
|||
prefixCls, |
|||
{ |
|||
[`${prefixCls}-rtl`]: direction === 'rtl', |
|||
}, |
|||
className, |
|||
hashId, |
|||
); |
|||
return wrapSSR( |
|||
<Component className={componentClassName} aria-label={ariaLabel} ref={mergedRef} {...restProps}> |
|||
{children} |
|||
</Component>, |
|||
); |
|||
}; |
|||
// Style
|
|||
const [wrapSSR, hashId] = useStyle(prefixCls); |
|||
|
|||
const componentClassName = classNames( |
|||
prefixCls, |
|||
{ |
|||
[`${prefixCls}-rtl`]: direction === 'rtl', |
|||
}, |
|||
className, |
|||
hashId, |
|||
); |
|||
|
|||
return wrapSSR( |
|||
// @ts-expect-error: Expression produces a union type that is too complex to represent.
|
|||
<Component className={componentClassName} ref={mergedRef} {...restProps}> |
|||
{children} |
|||
</Component>, |
|||
); |
|||
}, |
|||
); |
|||
|
|||
const RefTypography = React.forwardRef(Typography); |
|||
if (process.env.NODE_ENV !== 'production') { |
|||
RefTypography.displayName = 'Typography'; |
|||
Typography.displayName = 'Typography'; |
|||
} |
|||
|
|||
// es default export should use const instead of let
|
|||
const ExportTypography = RefTypography as unknown as React.FC<TypographyProps>; |
|||
|
|||
export default ExportTypography; |
|||
export default Typography; |
|||
|
@ -1,17 +0,0 @@ |
|||
version: '3' |
|||
services: |
|||
tests: |
|||
build: |
|||
context: . |
|||
dockerfile: Dockerfile.ui-test |
|||
volumes: |
|||
- './node_modules:/app/node_modules' |
|||
- './components:/app/components' |
|||
- './tests:/app/tests' |
|||
- './jest-stare:/app/jest-stare' |
|||
- './dist:/app/dist' |
|||
- '.jest.image.js:/app/.jest.image.js' |
|||
- './jest-puppeteer.config.js:/app/jest-puppeteer.config.js' |
|||
- './imageSnapshots:/app/imageSnapshots' |
|||
- './imageDiffSnapshots:/app/imageDiffSnapshots' |
|||
entrypoint: "npm run test-image:docker" |
Loading…
Reference in new issue