From 28f07f2bcb3a35731a649ea4793215af7320fff7 Mon Sep 17 00:00:00 2001 From: foryuki Date: Tue, 29 Nov 2022 22:13:43 +0800 Subject: [PATCH] docs: demos changed to data-driven --- .../__snapshots__/demo-extend.test.ts.snap | 24 +++++------ .../__tests__/__snapshots__/demo.test.ts.snap | 24 +++++------ components/anchor/demo/basic.tsx | 14 +++--- components/anchor/demo/customizeHighlight.tsx | 43 ++++++++++++++----- components/anchor/demo/onChange.tsx | 43 ++++++++++++++----- components/anchor/demo/onClick.tsx | 43 ++++++++++++++----- components/anchor/demo/static.tsx | 42 +++++++++++++----- components/anchor/demo/targetOffset.tsx | 42 +++++++++++++----- 8 files changed, 193 insertions(+), 82 deletions(-) diff --git a/components/anchor/__tests__/__snapshots__/demo-extend.test.ts.snap b/components/anchor/__tests__/__snapshots__/demo-extend.test.ts.snap index a615b7372ff9..582b236f7746 100644 --- a/components/anchor/__tests__/__snapshots__/demo-extend.test.ts.snap +++ b/components/anchor/__tests__/__snapshots__/demo-extend.test.ts.snap @@ -25,9 +25,9 @@ exports[`renders ./components/anchor/demo/basic.tsx extend context correctly 1`] - item Basic demo + Basic demo
Anchor Props -
diff --git a/components/anchor/__tests__/__snapshots__/demo.test.ts.snap b/components/anchor/__tests__/__snapshots__/demo.test.ts.snap index d8a5368f09de..2b3a5ebb0f74 100644 --- a/components/anchor/__tests__/__snapshots__/demo.test.ts.snap +++ b/components/anchor/__tests__/__snapshots__/demo.test.ts.snap @@ -25,9 +25,9 @@ exports[`renders ./components/anchor/demo/basic.tsx correctly 1`] = ` - item Basic demo + Basic demo
Anchor Props -
diff --git a/components/anchor/demo/basic.tsx b/components/anchor/demo/basic.tsx index ad3b2fb7c02b..2304490e9352 100644 --- a/components/anchor/demo/basic.tsx +++ b/components/anchor/demo/basic.tsx @@ -7,7 +7,7 @@ const App: React.FC = () => ( { key: '1', href: '#components-anchor-demo-basic', - title: 'item Basic demo', + title: 'Basic demo', }, { key: '2', @@ -23,13 +23,11 @@ const App: React.FC = () => ( key: '4', href: '#anchor-props', title: 'Anchor Props', - children: [ - { - key: '5', - href: '#link-props', - title: 'Link Props', - }, - ], + }, + { + key: '5', + href: '#link-props', + title: 'Link Props', }, ], }, diff --git a/components/anchor/demo/customizeHighlight.tsx b/components/anchor/demo/customizeHighlight.tsx index e746c2518dba..fed1ebb93213 100644 --- a/components/anchor/demo/customizeHighlight.tsx +++ b/components/anchor/demo/customizeHighlight.tsx @@ -1,19 +1,42 @@ import React from 'react'; import { Anchor } from 'antd'; -const { Link } = Anchor; - const getCurrentAnchor = () => '#components-anchor-demo-static'; const App: React.FC = () => ( - - - - - - - - + ); export default App; diff --git a/components/anchor/demo/onChange.tsx b/components/anchor/demo/onChange.tsx index f87d1703bb5c..da2f7b587e6b 100644 --- a/components/anchor/demo/onChange.tsx +++ b/components/anchor/demo/onChange.tsx @@ -1,21 +1,44 @@ import React from 'react'; import { Anchor } from 'antd'; -const { Link } = Anchor; - const onChange = (link: string) => { console.log('Anchor:OnChange', link); }; const App: React.FC = () => ( - - - - - - - - + ); export default App; diff --git a/components/anchor/demo/onClick.tsx b/components/anchor/demo/onClick.tsx index ddf88d865fcb..4f9866572db8 100644 --- a/components/anchor/demo/onClick.tsx +++ b/components/anchor/demo/onClick.tsx @@ -1,8 +1,6 @@ import React from 'react'; import { Anchor } from 'antd'; -const { Link } = Anchor; - const handleClick = ( e: React.MouseEvent, link: { @@ -15,14 +13,39 @@ const handleClick = ( }; const App: React.FC = () => ( - - - - - - - - + ); export default App; diff --git a/components/anchor/demo/static.tsx b/components/anchor/demo/static.tsx index a5dabdc510cd..be2d34c05303 100644 --- a/components/anchor/demo/static.tsx +++ b/components/anchor/demo/static.tsx @@ -1,17 +1,39 @@ import React from 'react'; import { Anchor } from 'antd'; -const { Link } = Anchor; - const App: React.FC = () => ( - - - - - - - - + ); export default App; diff --git a/components/anchor/demo/targetOffset.tsx b/components/anchor/demo/targetOffset.tsx index aaf022726718..fd69e252d3e8 100644 --- a/components/anchor/demo/targetOffset.tsx +++ b/components/anchor/demo/targetOffset.tsx @@ -1,8 +1,6 @@ import React, { useEffect, useState } from 'react'; import { Anchor } from 'antd'; -const { Link } = Anchor; - const App: React.FC = () => { const [targetOffset, setTargetOffset] = useState(undefined); @@ -11,14 +9,38 @@ const App: React.FC = () => { }, []); return ( - - - - - - - - + ); };