mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-16 14:52:31 +00:00
shared Input
This commit is contained in:
1 parent
723f2cba87
commit
281d7b2da2
23 files changed
+44
-299
No files matched your search
@@ -1,19 +0,0 @@
|
||||
import { Canvas, Meta } from '@storybook/blocks';
|
||||
|
||||
import * as InputStories from './Input.stories';
|
||||
|
||||
<Meta of={InputStories} />
|
||||
|
||||
# Input control
|
||||
|
||||
Here is the input with placeholder
|
||||
<Canvas of={InputStories.Default} />
|
||||
|
||||
Here is the input with icon
|
||||
<Canvas of={InputStories.WithIcon} />
|
||||
|
||||
Here is the input with label
|
||||
<Canvas of={InputStories.WithLabel} />
|
||||
|
||||
Here is the input with error message
|
||||
<Canvas of={InputStories.WithError} />
|
||||
@@ -1,50 +0,0 @@
|
||||
import type { Meta, StoryObj } from "@storybook/react";
|
||||
import { Input } from "./Input";
|
||||
import { withActions } from "@storybook/addon-actions/decorator";
|
||||
import { faUser } from "@fortawesome/pro-solid-svg-icons";
|
||||
|
||||
const meta: Meta<typeof Input> = {
|
||||
component: Input,
|
||||
parameters: {
|
||||
actions: {
|
||||
handles: ["change", "blur", "focus"],
|
||||
},
|
||||
},
|
||||
decorators: [withActions],
|
||||
};
|
||||
|
||||
type Story = StoryObj<typeof Input>;
|
||||
|
||||
export const Default: Story = {
|
||||
render: () => (
|
||||
<div className="bg-action p-8">
|
||||
<Input placeholder="field placeholder" />
|
||||
</div>
|
||||
),
|
||||
};
|
||||
|
||||
export const WithIcon: Story = {
|
||||
render: () => (
|
||||
<div className="bg-action p-8">
|
||||
<Input icon={faUser} />
|
||||
</div>
|
||||
),
|
||||
};
|
||||
|
||||
export const WithLabel: Story = {
|
||||
render: () => (
|
||||
<div className="bg-action p-8">
|
||||
<Input label="Input label" />
|
||||
</div>
|
||||
),
|
||||
};
|
||||
|
||||
export const WithError: Story = {
|
||||
render: () => (
|
||||
<div className="bg-action p-8">
|
||||
<Input errorMessage="Error message" />
|
||||
</div>
|
||||
),
|
||||
};
|
||||
|
||||
export default meta;
|
||||
@@ -1,83 +0,0 @@
|
||||
import React from "react";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
import { IconDefinition } from "@fortawesome/pro-solid-svg-icons";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import { Label, H6 } from "~/components";
|
||||
import { kebabCase } from "~/utilities";
|
||||
import {
|
||||
disableHotkeyInput,
|
||||
enableHotkeyInput,
|
||||
DomLevels,
|
||||
} from "~/pages/PageEnigma/signals";
|
||||
|
||||
interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
|
||||
inputClassName?: string;
|
||||
iconClassName?: string;
|
||||
label?: string;
|
||||
icon?: IconDefinition;
|
||||
isError?: boolean;
|
||||
errorMessage?: string;
|
||||
}
|
||||
|
||||
export const Input = React.forwardRef(
|
||||
(
|
||||
{
|
||||
label,
|
||||
icon,
|
||||
inputClassName,
|
||||
iconClassName,
|
||||
className,
|
||||
id,
|
||||
isError,
|
||||
onBlur,
|
||||
onFocus,
|
||||
errorMessage,
|
||||
...rest
|
||||
}: InputProps,
|
||||
ref: React.ForwardedRef<HTMLInputElement>,
|
||||
) => {
|
||||
return (
|
||||
<div className={twMerge("flex flex-col", className)}>
|
||||
{label && <Label htmlFor={id ? id : kebabCase(label)}>{label}</Label>}
|
||||
|
||||
<div className="relative w-full">
|
||||
{icon && (
|
||||
<FontAwesomeIcon
|
||||
icon={icon}
|
||||
className={twMerge("text-md absolute pl-3 pt-3", iconClassName)}
|
||||
/>
|
||||
)}
|
||||
<input
|
||||
ref={ref}
|
||||
id={id ? id : label ? kebabCase(label) : undefined}
|
||||
className={twMerge(
|
||||
"h-10 w-full rounded-lg bg-[#242424] px-3 py-2.5 text-white placeholder-white/50 outline-none",
|
||||
"hover:border-primary/60 focus:border-primary border border-[#363636] transition-all duration-150 ease-in-out focus:!outline-none",
|
||||
icon && "pl-10",
|
||||
isError && "outline-red focus:outline-red",
|
||||
inputClassName,
|
||||
)}
|
||||
onFocus={(e: React.FocusEvent<HTMLInputElement>) => {
|
||||
if (onFocus) {
|
||||
onFocus(e);
|
||||
}
|
||||
disableHotkeyInput(DomLevels.INPUT);
|
||||
}}
|
||||
onBlur={(e: React.FocusEvent<HTMLInputElement>) => {
|
||||
if (onBlur) {
|
||||
onBlur(e);
|
||||
}
|
||||
enableHotkeyInput(DomLevels.INPUT);
|
||||
}}
|
||||
{...rest}
|
||||
/>
|
||||
{errorMessage && (
|
||||
<H6 className="absolute z-10 text-red">{errorMessage}</H6>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
Input.displayName = "Input";
|
||||
@@ -1 +0,0 @@
|
||||
export * from "./Input";
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { Input } from "../Input";
|
||||
import { Input } from "@storyteller/ui-input";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import { faChevronDown, faChevronUp } from "@fortawesome/pro-solid-svg-icons";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { H6, Input, ListDropdown } from "~/components";
|
||||
import {
|
||||
Button
|
||||
} from "@storyteller/ui-button"
|
||||
import { H6, ListDropdown } from "~/components";
|
||||
import { Input } from "@storyteller/ui-input";
|
||||
import { Button } from "@storyteller/ui-button";
|
||||
import { FileUploader } from "./FileUploader";
|
||||
import { useState } from "react";
|
||||
import {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { useCallback, useEffect, useState, useRef } from "react";
|
||||
import { H6, Input, Label, ListDropdown } from "~/components";
|
||||
import {
|
||||
Button
|
||||
} from "@storyteller/ui-button"
|
||||
import { H6, ListDropdown } from "~/components";
|
||||
import { Button } from "@storyteller/ui-button";
|
||||
import { Input } from "@storyteller/ui-input";
|
||||
import { Label } from "@storyteller/ui-label";
|
||||
import { FileUploader } from "../UploadModal/FileUploader";
|
||||
import { loadPreviewOnCanvas, snapshotCanvasAsThumbnail } from "./utilities";
|
||||
import { upload3DObjects } from "./utilities/upload3DObjects";
|
||||
|
||||
+3
-2
@@ -1,6 +1,7 @@
|
||||
import { useState } from "react";
|
||||
import { H6, Input } from "~/components";
|
||||
import { Button } from "@storyteller/ui-button"
|
||||
import { H6 } from "~/components";
|
||||
import { Button } from "@storyteller/ui-button";
|
||||
import { Input } from "@storyteller/ui-input";
|
||||
import { FileUploader } from "../UploadModal/FileUploader";
|
||||
import { uploadPlane } from "./uploadPlane";
|
||||
import { UploaderState } from "~/models";
|
||||
|
||||
+14
-19
@@ -1,9 +1,8 @@
|
||||
import { useState } from "react";
|
||||
|
||||
import { H6, Input } from "~/components";
|
||||
import { Button } from "@storyteller/ui-button"
|
||||
import { H6 } from "~/components";
|
||||
import { Button } from "@storyteller/ui-button";
|
||||
import { Input } from "@storyteller/ui-input";
|
||||
import { FileUploader } from "../UploadModal/FileUploader";
|
||||
|
||||
import { UploaderState } from "~/models";
|
||||
import { uploadImage } from "./uploadImage";
|
||||
|
||||
@@ -59,7 +58,7 @@ export const UploadImageMedia = ({
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="mb-4 flex flex-col gap-4" >
|
||||
<div className="mb-4 flex flex-col gap-4">
|
||||
<Input
|
||||
placeholder="Enter the title here"
|
||||
errorMessage={uploadTitle.error}
|
||||
@@ -82,34 +81,30 @@ export const UploadImageMedia = ({
|
||||
}
|
||||
}}
|
||||
/>
|
||||
{
|
||||
assetFile.error && (
|
||||
<H6 className="z-10 text-red" > {assetFile.error} </H6>
|
||||
)
|
||||
}
|
||||
{assetFile.error && (
|
||||
<H6 className="z-10 text-red"> {assetFile.error} </H6>
|
||||
)}
|
||||
|
||||
<div className="relative m-auto aspect-square w-full overflow-hidden rounded-lg bg-brand-secondary" >
|
||||
<div className="relative m-auto aspect-square w-full overflow-hidden rounded-lg bg-brand-secondary">
|
||||
{!assetFile.value && (
|
||||
<H6 className="absolute left-0 top-1/2 -mt-5 w-full text-center" >
|
||||
<H6 className="absolute left-0 top-1/2 -mt-5 w-full text-center">
|
||||
File Preview
|
||||
</H6>
|
||||
)}
|
||||
{
|
||||
assetFile.value &&
|
||||
{assetFile.value && (
|
||||
<img
|
||||
alt="file upload preview"
|
||||
className="m-auto max-h-full max-w-full"
|
||||
src={assetFile.src}
|
||||
/>
|
||||
|
||||
}
|
||||
)}
|
||||
</div>
|
||||
|
||||
< div className="flex justify-end gap-4" >
|
||||
<Button variant="primary" onClick={handleSubmit} >
|
||||
<div className="flex justify-end gap-4">
|
||||
<Button variant="primary" onClick={handleSubmit}>
|
||||
Upload
|
||||
</Button>
|
||||
< Button variant="secondary" onClick={onClose} >
|
||||
<Button variant="secondary" onClick={onClose}>
|
||||
Cancel
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
export * from "./FileUploader";
|
||||
export * from "./FilterButtons";
|
||||
export * from "./Gravatar";
|
||||
export * from "./Input";
|
||||
export * from "./InputVector";
|
||||
export * from "./ListDropdown";
|
||||
export * from "./LoadingBar";
|
||||
|
||||
@@ -3,15 +3,14 @@ import { twMerge } from "tailwind-merge";
|
||||
import { useSignals } from "@preact/signals-react/runtime";
|
||||
import { faPencil, faSpinnerThird } from "@fortawesome/pro-solid-svg-icons";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import { scene, signalScene, authentication, currentPage } from "~/signals";
|
||||
import { scene, signalScene, authentication } from "~/signals";
|
||||
import {
|
||||
showErrorDialog,
|
||||
errorDialogMessage,
|
||||
errorDialogTitle,
|
||||
} from "~/pages/PageEnigma/signals";
|
||||
import { Input } from "~/components";
|
||||
import { Input } from "@storyteller/ui-input";
|
||||
import { MediaFilesApi } from "~/Classes/ApiManager/MediaFilesApi";
|
||||
import { Pages } from "~/pages/PageEnigma/constants/page";
|
||||
|
||||
interface Props {
|
||||
pageName: string;
|
||||
|
||||
+2
-5
@@ -30,12 +30,9 @@ export type TextFormatData = {
|
||||
export type TextNodeData = {
|
||||
text: string;
|
||||
} & TextFormatData;
|
||||
|
||||
import { useState } from "react";
|
||||
|
||||
import { DialogTitle } from "@headlessui/react";
|
||||
import { Button, TextEditor } from "../../../components/ui";
|
||||
|
||||
import { TextEditor } from "../../../components/ui";
|
||||
import { Button } from "@storyteller/ui-button";
|
||||
import { Modal } from "@storyteller/ui-modal";
|
||||
|
||||
export const DialogEditText = ({
|
||||
|
||||
+5
-2
@@ -1,13 +1,16 @@
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
import { dialogPanelStyles, paperWrapperStyles } from "../../../components/styles";
|
||||
import {
|
||||
dialogPanelStyles,
|
||||
paperWrapperStyles,
|
||||
} from "../../../components/styles";
|
||||
import {
|
||||
Description,
|
||||
Dialog,
|
||||
DialogPanel,
|
||||
DialogTitle,
|
||||
} from "@headlessui/react";
|
||||
import { Button } from "../../../components/ui";
|
||||
import { Button } from "@storyteller/ui-button";
|
||||
|
||||
export const DialogError = ({
|
||||
isShowing,
|
||||
|
||||
+3
-5
@@ -1,5 +1,6 @@
|
||||
import { faCameraMovie, faPlayCircle } from "@fortawesome/pro-solid-svg-icons";
|
||||
import { Button, Tooltip } from "~/components/ui";
|
||||
import { Button } from "@storyteller/ui-button";
|
||||
import { Tooltip } from "@storyteller/ui-tooltip";
|
||||
import { ToolbarButtonProps } from "../ToolbarButton";
|
||||
|
||||
export const ButtonPreviewAndRender = ({
|
||||
@@ -9,10 +10,7 @@ export const ButtonPreviewAndRender = ({
|
||||
buttonPreviewProps: ToolbarButtonProps;
|
||||
buttonRenderProps: ToolbarButtonProps;
|
||||
}) => {
|
||||
return (
|
||||
<div className="flex">
|
||||
</div>
|
||||
);
|
||||
return <div className="flex"></div>;
|
||||
};
|
||||
const ButtonPreview = (buttonProps: ToolbarButtonProps) => {
|
||||
const {
|
||||
|
||||
@@ -1,86 +0,0 @@
|
||||
import React from "react";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
import { IconDefinition } from "@fortawesome/pro-solid-svg-icons";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import { kebabCase } from "~/utilities";
|
||||
|
||||
interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
|
||||
inputClassName?: string;
|
||||
iconClassName?: string;
|
||||
label?: string;
|
||||
icon?: IconDefinition;
|
||||
isError?: boolean;
|
||||
errorMessage?: string;
|
||||
}
|
||||
|
||||
export const Input = React.forwardRef(
|
||||
(
|
||||
{
|
||||
label,
|
||||
icon,
|
||||
inputClassName,
|
||||
iconClassName,
|
||||
className,
|
||||
id,
|
||||
isError,
|
||||
onBlur,
|
||||
onFocus,
|
||||
errorMessage,
|
||||
...rest
|
||||
}: InputProps,
|
||||
ref: React.ForwardedRef<HTMLInputElement>,
|
||||
) => {
|
||||
return (
|
||||
<div className={twMerge("flex flex-col", className)}>
|
||||
{label && (
|
||||
<label
|
||||
htmlFor={id ? id : kebabCase(label)}
|
||||
className="pb-2 font-medium"
|
||||
>
|
||||
{label}
|
||||
</label>
|
||||
)}
|
||||
|
||||
<div className="relative w-full">
|
||||
{icon && (
|
||||
<FontAwesomeIcon
|
||||
icon={icon}
|
||||
className={twMerge(
|
||||
"absolute pl-3.5 pt-3 text-sm opacity-70",
|
||||
iconClassName,
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
<input
|
||||
ref={ref}
|
||||
id={id ? id : label ? kebabCase(label) : undefined}
|
||||
className={twMerge(
|
||||
"h-10 w-full rounded-md px-3 py-2.5 outline-1 outline-ui-border",
|
||||
// on focus
|
||||
"outline-offset-0 transition-all duration-150 ease-in-out focus:outline-primary",
|
||||
icon && "pl-10",
|
||||
isError && "outline-red focus:outline-red",
|
||||
inputClassName,
|
||||
)}
|
||||
onFocus={(e: React.FocusEvent<HTMLInputElement>) => {
|
||||
if (onFocus) {
|
||||
onFocus(e);
|
||||
}
|
||||
}}
|
||||
onBlur={(e: React.FocusEvent<HTMLInputElement>) => {
|
||||
if (onBlur) {
|
||||
onBlur(e);
|
||||
}
|
||||
}}
|
||||
{...rest}
|
||||
/>
|
||||
{errorMessage && (
|
||||
<h6 className="text-red absolute z-10">{errorMessage}</h6>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
Input.displayName = "Input";
|
||||
@@ -2,8 +2,7 @@ import React, { useEffect, useState } from "react";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import { faChevronDown, faChevronUp } from "@fortawesome/pro-solid-svg-icons";
|
||||
|
||||
import { Input } from "./Input";
|
||||
import { Input } from "@storyteller/ui-input";
|
||||
|
||||
interface NumberInputProps {
|
||||
value: number;
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ import { twMerge } from "tailwind-merge";
|
||||
|
||||
import { paperWrapperStyles } from "../../../components/styles";
|
||||
import { Button } from "../Button";
|
||||
import { Input } from "../Input";
|
||||
import { Input } from "@storyteller/ui-input";
|
||||
import { HexEyedropPicker } from "../HexEyedropPicker";
|
||||
|
||||
export const ColorPicker = ({
|
||||
|
||||
+3
-4
@@ -8,12 +8,11 @@ import { Popover, PopoverButton, PopoverPanel } from "@headlessui/react";
|
||||
import { ChangeEvent, useEffect, useState } from "react";
|
||||
import { HexColorPicker } from "react-colorful";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
import { useSignals } from "@preact/signals-react/runtime";
|
||||
import { paperWrapperStyles } from "~/components/styles";
|
||||
import { Button } from "../Button";
|
||||
import { Button } from "@storyteller/ui-button";
|
||||
import { HexEyedropPicker } from "../HexEyedropPicker";
|
||||
import { Input } from "../Input";
|
||||
import { Input } from "@storyteller/ui-input";
|
||||
|
||||
export const BackgroundMenu = ({
|
||||
color: prevColor,
|
||||
@@ -90,7 +89,7 @@ export const BackgroundMenu = ({
|
||||
if (streamChanges) {
|
||||
onChange(color);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Rerender the component when these signals change:
|
||||
useSignals();
|
||||
|
||||
-1
@@ -8,7 +8,6 @@ import { Popover, PopoverButton, PopoverPanel } from "@headlessui/react";
|
||||
import { ChangeEvent, useEffect, useState, useRef } from "react";
|
||||
import { HexAlphaColorPicker } from "react-colorful";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
import { useSignals } from "@preact/signals-react/runtime";
|
||||
import { paperWrapperStyles } from "../../../components/styles";
|
||||
import {
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
export * from "./Button";
|
||||
export * from "./Input";
|
||||
export * from "./InputNumber";
|
||||
export * from "./LoadingBar";
|
||||
export * from "./LoadingSpinner";
|
||||
|
||||
@@ -5,7 +5,6 @@ import { Input } from "@storyteller/ui-input";
|
||||
import { Label } from "@storyteller/ui-label";
|
||||
import { Button } from "@storyteller/ui-button";
|
||||
import { Modal } from "@storyteller/ui-modal";
|
||||
|
||||
import {
|
||||
faArrowDownToLine,
|
||||
faArrowRight,
|
||||
@@ -16,7 +15,6 @@ import {
|
||||
import SocialButton from "./SocialButton";
|
||||
import { generateMovieId, viewMyMovies } from "~/pages/PageEnigma/signals";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
import { downloadFile } from "~/pages/PageEnigma/comps/GenerateModals/utils/downloadFile";
|
||||
import { GetCdnOrigin } from "~/api/GetCdnOrigin";
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
faLockOpen,
|
||||
faXmark,
|
||||
} from "@fortawesome/pro-solid-svg-icons";
|
||||
import { Input } from "~/components";
|
||||
import { Input } from "@storyteller/ui-input";
|
||||
import { Button } from "@storyteller/ui-button";
|
||||
import { Transition } from "@headlessui/react";
|
||||
import { twMerge } from "tailwind-merge";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { faEnvelope, faKey, faUser } from "@fortawesome/pro-solid-svg-icons";
|
||||
import { GlobalSettingsManager } from "./pages/PageEnigma/GlobalSettingsManager";
|
||||
import { Input } from "~/components";
|
||||
import { Input } from "@storyteller/ui-input";
|
||||
import { Button } from "@storyteller/ui-button";
|
||||
import { addToast, authentication, signUp } from "~/signals";
|
||||
import { FormEvent, useRef, useState, StrictMode } from "react";
|
||||
|
||||
Reference in new issue
Block a user