Unverified Commit a0d1d728 authored by lijianan's avatar lijianan Committed by GitHub

examples: update examples with-ant-design (#52896)



demo: update examples with-ant-design

- https://github.com/ant-design/ant-design/pull/43663
parent 97a0a337
'use client'
import React from 'react'
import { useServerInsertedHTML } from 'next/navigation'
import { StyleProvider, createCache, extractStyle } from '@ant-design/cssinjs'
interface StyledRegistryProps {
children: React.ReactNode
}
const StyledComponentsRegistry = ({ children }: StyledRegistryProps) => {
const cache = createCache()
useServerInsertedHTML(() => (
<style
id="antd"
dangerouslySetInnerHTML={{ __html: extractStyle(cache, true) }}
/>
))
return <StyleProvider cache={cache}>{children}</StyleProvider>
}
export default StyledComponentsRegistry
@tailwind base;
@tailwind components;
@tailwind utilities;
:root {
--foreground-rgb: 0, 0, 0;
--background-start-rgb: 214, 219, 220;
--background-end-rgb: 255, 255, 255;
}
body {
color: rgb(var(--foreground-rgb));
background: linear-gradient(
to bottom,
transparent,
rgb(var(--background-end-rgb))
)
rgb(var(--background-start-rgb));
}
import React from 'react'
import type { Metadata } from 'next'
import { Inter } from 'next/font/google'
import StyledComponentsRegistry from './AntdRegistry'
import './globals.css'
const inter = Inter({ subsets: ['latin'] })
export const metadata: Metadata = {
title: 'Create Next App',
description: 'Generated by create next app',
}
interface RootLayoutProps {
children: React.ReactNode
}
function RootLayout({ children }: RootLayoutProps) {
return (
<html lang="en">
<body className={inter.className}>
<StyledComponentsRegistry>{children}</StyledComponentsRegistry>
</body>
</html>
)
}
export default RootLayout
'use client'
import React from 'react'
import Link from 'next/link'
import { SmileFilled } from '@ant-design/icons'
import {
Button,
DatePicker,
......@@ -6,32 +11,17 @@ import {
Select,
Slider,
Switch,
ConfigProvider,
} from 'antd'
import type { DatePickerProps } from 'antd'
import { SmileFilled } from '@ant-design/icons'
import Link from 'next/link'
const FormItem = Form.Item
const content = {
marginTop: '100px',
}
import theme from './themeConfig'
export default function Home() {
const onDatePickerChange: DatePickerProps['onChange'] = (
date,
dateString
) => {
console.log(date, dateString)
}
return (
<div style={content}>
const HomePage = () => (
<ConfigProvider theme={theme}>
<div style={{ padding: 100, height: '100vh' }}>
<div className="text-center mb-5">
<Link href="#" className="logo mr-0">
<SmileFilled style={{ fontSize: 48 }} />
</Link>
<p className="mb-0 mt-3 text-disabled">Welcome to the world !</p>
</div>
<div>
......@@ -41,7 +31,7 @@ export default function Home() {
labelCol={{ span: 8 }}
wrapperCol={{ span: 8 }}
>
<FormItem label="Input Number">
<Form.Item label="Input Number">
<InputNumber
min={1}
max={10}
......@@ -49,53 +39,39 @@ export default function Home() {
defaultValue={3}
name="inputNumber"
/>
</FormItem>
<FormItem label="Switch">
</Form.Item>
<Form.Item label="Switch">
<Switch defaultChecked />
</FormItem>
<FormItem label="Slider">
</Form.Item>
<Form.Item label="Slider">
<Slider defaultValue={70} />
</FormItem>
<FormItem label="Select">
</Form.Item>
<Form.Item label="Select">
<Select
defaultValue="lucy"
style={{ width: 192 }}
options={[
{
value: 'jack',
label: 'Jack',
},
{
value: 'lucy',
label: 'Lucy',
},
{
value: 'disabled',
disabled: true,
label: 'Disabled',
},
{
value: 'Yiminghe',
label: 'yiminghe',
},
{ value: 'jack', label: 'Jack' },
{ value: 'lucy', label: 'Lucy' },
{ value: 'Yiminghe', label: 'yiminghe' },
{ value: 'lijianan', label: 'lijianan' },
{ value: 'disabled', label: 'Disabled', disabled: true },
]}
/>
</FormItem>
<FormItem label="DatePicker">
<DatePicker showTime onChange={onDatePickerChange} />
</FormItem>
<FormItem style={{ marginTop: 48 }} wrapperCol={{ offset: 8 }}>
</Form.Item>
<Form.Item label="DatePicker">
<DatePicker showTime />
</Form.Item>
<Form.Item style={{ marginTop: 48 }} wrapperCol={{ offset: 8 }}>
<Button type="primary" htmlType="submit">
OK
</Button>
<Button style={{ marginLeft: 8 }}>Cancel</Button>
</FormItem>
</Form.Item>
</Form>
</div>
</div>
)
}
</ConfigProvider>
)
export default HomePage
import type { ThemeConfig } from 'antd'
const theme: ThemeConfig = {
token: {
fontSize: 16,
colorPrimary: '#52c41a',
},
}
export default theme
......@@ -6,20 +6,20 @@
"start": "next start"
},
"dependencies": {
"@ant-design/icons": "^4.8.0",
"@ant-design/icons": "^5.1.4",
"antd": "^5.0.0",
"next": "latest",
"react": "18.2.0",
"react-dom": "18.2.0"
},
"devDependencies": {
"@types/node": "^20.4.5",
"@types/react": "^18.2.17",
"@types/react-dom": "^18.2.7",
"typescript": "^5.1.6"
},
"browser": {
"fs": false,
"path": false
},
"devDependencies": {
"@types/node": "18.0.3",
"@types/react": "18.0.15",
"@types/react-dom": "18.0.6",
"typescript": "4.7.4"
}
}
import type { AppProps } from 'next/app'
import 'antd/dist/reset.css'
import '../styles/vars.css'
import '../styles/global.css'
function MyApp({ Component, pageProps }: AppProps) {
return <Component {...pageProps} />
}
export default MyApp
*,
*:before,
*:after {
box-sizing: inherit;
}
html {
box-sizing: border-box;
font-size: 14px;
-ms-overflow-style: -ms-autohiding-scrollbar;
}
body {
background-color: var(--backgroundColor);
-ms-text-size-adjust: 100%;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-rendering: optimizeLegibility;
}
.text-left {
text-align: left !important;
}
.text-right {
text-align: right !important;
}
.text-center {
text-align: center !important;
}
.m-0 {
margin: 0 !important;
}
.mt-0,
.my-0 {
margin-top: 0 !important;
}
.mr-0,
.mx-0 {
margin-right: 0 !important;
}
.mb-0,
.my-0 {
margin-bottom: 0 !important;
}
.ml-0,
.mx-0 {
margin-left: 0 !important;
}
.m-1 {
margin: 0.25rem !important;
}
.mt-1,
.my-1 {
margin-top: 0.25rem !important;
}
.mr-1,
.mx-1 {
margin-right: 0.25rem !important;
}
.mb-1,
.my-1 {
margin-bottom: 0.25rem !important;
}
.ml-1,
.mx-1 {
margin-left: 0.25rem !important;
}
.m-2 {
margin: 0.5rem !important;
}
.mt-2,
.my-2 {
margin-top: 0.5rem !important;
}
.mr-2,
.mx-2 {
margin-right: 0.5rem !important;
}
.mb-2,
.my-2 {
margin-bottom: 0.5rem !important;
}
.ml-2,
.mx-2 {
margin-left: 0.5rem !important;
}
.m-3 {
margin: 1rem !important;
}
.mt-3,
.my-3 {
margin-top: 1rem !important;
}
.mr-3,
.mx-3 {
margin-right: 1rem !important;
}
.mb-3,
.my-3 {
margin-bottom: 1rem !important;
}
.ml-3,
.mx-3 {
margin-left: 1rem !important;
}
.m-4 {
margin: 1.5rem !important;
}
.mt-4,
.my-4 {
margin-top: 1.5rem !important;
}
.mr-4,
.mx-4 {
margin-right: 1.5rem !important;
}
.mb-4,
.my-4 {
margin-bottom: 1.5rem !important;
}
.ml-4,
.mx-4 {
margin-left: 1.5rem !important;
}
.m-5 {
margin: 3rem !important;
}
.mt-5,
.my-5 {
margin-top: 3rem !important;
}
.mr-5,
.mx-5 {
margin-right: 3rem !important;
}
.mb-5,
.my-5 {
margin-bottom: 3rem !important;
}
.ml-5,
.mx-5 {
margin-left: 3rem !important;
}
.logo {
display: flex;
align-items: center;
margin-right: 1rem;
font-size: 1.25rem;
white-space: nowrap;
color: var(--primaryColor);
justify-content: center;
}
.logo > svg {
fill: var(--primaryColor);
}
.text-disabled {
color: var(--textColorSecondary) !important;
}
:root {
--backgroundColor: #f7f7f7;
--primaryColor: #191a1b;
--textColorSecondary: rgba(0, 0, 0, 0.45);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment