From 1840679d3c368cc18d4e305be5498382865ee764 Mon Sep 17 00:00:00 2001 From: TheoryOfNekomata Date: Tue, 26 Sep 2023 17:22:38 +0800 Subject: [PATCH] Update implementation Test implementation on both client-side and server-side. --- packages/iceform-next-sandbox/next.config.js | 7 +- packages/iceform-next-sandbox/package.json | 3 + .../src/components/ActionButton.tsx | 34 ++++ .../src/components/MultilineTextInput.tsx | 41 ++++ .../src/components/TextInput.tsx | 36 ++++ .../src/pages/notes/[noteId].tsx | 120 +++++++----- .../src/pages/notes/index.tsx | 181 ++++++++++++++---- .../iceform-next-sandbox/tailwind.config.ts | 3 + packages/iceform-next/src/server/action.ts | 2 +- pnpm-lock.yaml | 85 ++++++-- 10 files changed, 414 insertions(+), 98 deletions(-) create mode 100644 packages/iceform-next-sandbox/src/components/ActionButton.tsx create mode 100644 packages/iceform-next-sandbox/src/components/MultilineTextInput.tsx create mode 100644 packages/iceform-next-sandbox/src/components/TextInput.tsx diff --git a/packages/iceform-next-sandbox/next.config.js b/packages/iceform-next-sandbox/next.config.js index a843cbe..500f490 100644 --- a/packages/iceform-next-sandbox/next.config.js +++ b/packages/iceform-next-sandbox/next.config.js @@ -1,6 +1,9 @@ /** @type {import('next').NextConfig} */ const nextConfig = { reactStrictMode: true, -} + experimental: { + optimizeCss: true, + }, +}; -module.exports = nextConfig +module.exports = nextConfig; diff --git a/packages/iceform-next-sandbox/package.json b/packages/iceform-next-sandbox/package.json index 525d2db..92110f9 100644 --- a/packages/iceform-next-sandbox/package.json +++ b/packages/iceform-next-sandbox/package.json @@ -23,5 +23,8 @@ "react-dom": "18.2.0", "tailwindcss": "3.3.3", "typescript": "5.2.2" + }, + "devDependencies": { + "critters": "^0.0.20" } } diff --git a/packages/iceform-next-sandbox/src/components/ActionButton.tsx b/packages/iceform-next-sandbox/src/components/ActionButton.tsx new file mode 100644 index 0000000..9f520a9 --- /dev/null +++ b/packages/iceform-next-sandbox/src/components/ActionButton.tsx @@ -0,0 +1,34 @@ +import * as React from 'react'; + +export const ActionButtonDerivedElementComponent = 'button' as const; + +export type ActionButtonDerivedElement = HTMLElementTagNameMap[typeof ActionButtonDerivedElementComponent]; + +export interface ActionButtonProps extends React.HTMLProps { + primary?: boolean; +} + +type ButtonType = 'button' | 'reset' | 'submit' | undefined; + +export const ActionButton = React.forwardRef(({ + primary, + children, + type, + className, + ...etcProps +}, forwardedRef) => { + return ( + + ) +}); + +ActionButton.displayName = 'ActionButton'; diff --git a/packages/iceform-next-sandbox/src/components/MultilineTextInput.tsx b/packages/iceform-next-sandbox/src/components/MultilineTextInput.tsx new file mode 100644 index 0000000..e5dea04 --- /dev/null +++ b/packages/iceform-next-sandbox/src/components/MultilineTextInput.tsx @@ -0,0 +1,41 @@ +import * as React from 'react'; + +export const MultilineTextInputDerivedElementComponent = 'textarea' as const; + +export type MultilineTextInputDerivedElement = HTMLElementTagNameMap[typeof MultilineTextInputDerivedElementComponent]; + +export interface MultilineTextInputProps extends Omit, 'label'> { + label?: React.ReactNode; +} + +export const MultilineTextInput = React.forwardRef(({ + className = 'inline-block', + style, + label, + rows = 3, + ...etcProps +}, forwardedRef) => { + return ( +
+ +
+ ); +}); + +MultilineTextInput.displayName = 'TextInput'; diff --git a/packages/iceform-next-sandbox/src/components/TextInput.tsx b/packages/iceform-next-sandbox/src/components/TextInput.tsx new file mode 100644 index 0000000..7074b49 --- /dev/null +++ b/packages/iceform-next-sandbox/src/components/TextInput.tsx @@ -0,0 +1,36 @@ +import * as React from 'react'; + +export const TextInputDerivedElementComponent = 'input' as const; + +export type TextInputDerivedElement = HTMLElementTagNameMap[typeof TextInputDerivedElementComponent]; + +export interface TextInputProps extends Omit, 'label'> { + label?: React.ReactNode; +} + +export const TextInput = React.forwardRef(({ + className = 'inline-block', + style, + label, + ...etcProps +}, forwardedRef) => { + return ( +
+ +
+ ); +}); + +TextInput.displayName = 'TextInput'; diff --git a/packages/iceform-next-sandbox/src/pages/notes/[noteId].tsx b/packages/iceform-next-sandbox/src/pages/notes/[noteId].tsx index 7b222ab..23d2fbd 100644 --- a/packages/iceform-next-sandbox/src/pages/notes/[noteId].tsx +++ b/packages/iceform-next-sandbox/src/pages/notes/[noteId].tsx @@ -1,6 +1,9 @@ import * as Iceform from '@modal-sh/iceform-next'; import * as React from 'react'; import { useRouter } from 'next/router'; +import { TextInput } from '@/components/TextInput'; +import { MultilineTextInput } from '@/components/MultilineTextInput'; +import { ActionButton } from '@/components/ActionButton'; export interface NotesItemPageProps { note: { @@ -38,54 +41,75 @@ const NotesItemPage: Iceform.NextPage = ({ }, [response]); return ( -
- -
- -
-
- -
-
-