Skip to content

Commit ea89928

Browse files
committed
feat: Add Textarea component and dynamic Storybook manager-head setup
- Introduce `Textarea` component with forwardRef and styles for reusability. - Add script to dynamically configure Storybook `manager-head` for dev and build modes. - Update `package.json` to integrate the setup script in Storybook commands.
1 parent c8f3586 commit ea89928

6 files changed

Lines changed: 69 additions & 2 deletions

File tree

.storybook/manager-head.build.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<link rel="icon" href="/scheduler-icon.svg" type="image/svg+xml" />
2+
<title>React Cron Field</title>
3+
<base href="/react-cron-field/"/>

.storybook/manager-head.dev.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<link rel="icon" href="/scheduler-icon.svg" type="image/svg+xml" />
2+
<title>React Cron Field</title>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<link rel="icon" href="/scheduler-icon.svg" type="image/svg+xml" />
2+
<title>React Cron Field</title>
3+
<base href="/react-cron-field/"/>

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
"type-check": "tsc -b",
2323
"lint": "eslint .",
2424
"preview": "vite preview",
25-
"storybook": "storybook dev -p 6006",
26-
"build-storybook": "storybook build",
25+
"storybook": "./scripts/setup-storybook-head.sh dev && storybook dev -p 6006",
26+
"build-storybook": "./scripts/setup-storybook-head.sh build && storybook build",
2727
"deploy-storybook": "npm run build-storybook && gh-pages -d storybook-static"
2828
},
2929
"peerDependencies": {

scripts/setup-storybook-head.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
3+
# Define paths
4+
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
5+
STORYBOOK_DIR="$ROOT_DIR/.storybook"
6+
MANAGER_HEAD="$STORYBOOK_DIR/manager-head.html"
7+
MANAGER_HEAD_DEV="$STORYBOOK_DIR/manager-head.dev.html"
8+
MANAGER_HEAD_BUILD="$STORYBOOK_DIR/manager-head.build.html"
9+
10+
# Check if this is the first run and we need to create the build version
11+
if [ ! -f "$MANAGER_HEAD_BUILD" ]; then
12+
# Create manager-head.build.html with base href tag
13+
cp "$MANAGER_HEAD" "$MANAGER_HEAD_BUILD"
14+
15+
# Ensure it has the base href tag
16+
if ! grep -q "<base href=\"/react-cron-field/\"/>" "$MANAGER_HEAD_BUILD"; then
17+
echo "Adding base href tag to $MANAGER_HEAD_BUILD"
18+
# If there's no base href tag, add it after the title tag
19+
sed -i 's/<title>React Cron Field<\/title>/<title>React Cron Field<\/title>\n<base href="\/react-cron-field\/"\/>/g' "$MANAGER_HEAD_BUILD"
20+
fi
21+
fi
22+
23+
# Check the mode parameter
24+
MODE=$1
25+
26+
if [ "$MODE" == "dev" ]; then
27+
echo "Setting up Storybook for development mode"
28+
cp "$MANAGER_HEAD_DEV" "$MANAGER_HEAD"
29+
elif [ "$MODE" == "build" ]; then
30+
echo "Setting up Storybook for build mode"
31+
cp "$MANAGER_HEAD_BUILD" "$MANAGER_HEAD"
32+
else
33+
echo "Usage: $0 [dev|build]"
34+
exit 1
35+
fi
36+
37+
echo "Storybook manager-head.html configured for $MODE mode"

src/components/ui/textarea.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import * as React from "react"
2+
3+
import { cn } from "@/lib/utils"
4+
5+
const Textarea = React.forwardRef<
6+
HTMLTextAreaElement,
7+
React.ComponentProps<"textarea">
8+
>(({ className, ...props }, ref) => {
9+
return (
10+
<textarea
11+
className={cn(
12+
"flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
13+
className
14+
)}
15+
ref={ref}
16+
{...props}
17+
/>
18+
)
19+
})
20+
Textarea.displayName = "Textarea"
21+
22+
export { Textarea }

0 commit comments

Comments
 (0)