mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-16 06:42:14 +00:00
select field component
This commit is contained in:
1 parent
c2c994949f
commit
be35c6269c
4 files changed
+181
-12
No files matched your search
@@ -0,0 +1,68 @@
|
||||
@import "scss/colours.scss";
|
||||
|
||||
.select__control {
|
||||
&.select {
|
||||
height: 48px;
|
||||
border-width: 2px;
|
||||
padding-left: 0.15rem;
|
||||
padding-right: 0.15rem;
|
||||
background-color: $input-dark;
|
||||
border-radius: 0.5rem;
|
||||
border-color: $input-dark !important;
|
||||
box-shadow: none;
|
||||
cursor: pointer;
|
||||
|
||||
&.no-padding {
|
||||
padding-left: 0.5rem;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background-color: lighten($input-dark, 5%);
|
||||
border-color: lighten($input-dark, 5%) !important;
|
||||
}
|
||||
|
||||
&.focused {
|
||||
border-color: $primary !important;
|
||||
}
|
||||
|
||||
&.with-icon {
|
||||
padding-left: 2rem;
|
||||
}
|
||||
|
||||
&.rounded-full {
|
||||
border-radius: 50px;
|
||||
}
|
||||
}
|
||||
|
||||
&.select-option {
|
||||
background-color: $input-dark;
|
||||
cursor: pointer;
|
||||
padding: 0.5rem 1rem;
|
||||
|
||||
&:hover {
|
||||
background-color: lighten($input-dark, 8%);
|
||||
}
|
||||
}
|
||||
|
||||
&.select-input,
|
||||
&.select-value {
|
||||
color: $white;
|
||||
}
|
||||
|
||||
&.select-placeholder {
|
||||
color: $white !important;
|
||||
}
|
||||
|
||||
&.select-container {
|
||||
background: $input-dark;
|
||||
margin-top: 6px;
|
||||
padding: 0;
|
||||
border-radius: 0.5rem;
|
||||
z-index: 3;
|
||||
}
|
||||
|
||||
&.select-separator {
|
||||
width: 1px;
|
||||
opacity: 0.3;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,31 @@
|
||||
import React from "react";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import { IconDefinition } from "@fortawesome/fontawesome-svg-core";
|
||||
import "./Input.scss";
|
||||
import {
|
||||
default as ReactSelect,
|
||||
Props as ReactSelectProps,
|
||||
} from "react-select";
|
||||
|
||||
interface InputProps extends React.InputHTMLAttributes<HTMLInputElement> {
|
||||
icon?: IconDefinition;
|
||||
label?: string;
|
||||
textArea?: boolean;
|
||||
}
|
||||
|
||||
export default function Input({ label, icon, ...rest }: InputProps) {
|
||||
interface TextAreaProps
|
||||
extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {
|
||||
label?: string;
|
||||
textArea?: boolean;
|
||||
}
|
||||
|
||||
interface SelectProps extends ReactSelectProps {
|
||||
icon?: IconDefinition;
|
||||
label?: string;
|
||||
rounded?: boolean;
|
||||
}
|
||||
|
||||
export function Input({ label, icon, textArea, ...rest }: InputProps) {
|
||||
return (
|
||||
<div>
|
||||
{label && <label className="sub-title">{label}</label>}
|
||||
@@ -21,3 +39,54 @@ export default function Input({ label, icon, ...rest }: InputProps) {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function TextArea({ label, textArea, ...rest }: TextAreaProps) {
|
||||
return (
|
||||
<div>
|
||||
{label && <label className="sub-title">{label}</label>}
|
||||
|
||||
<div className="form-group">
|
||||
<textarea className="form-control" {...rest} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function Select({ label, icon, rounded, ...rest }: SelectProps) {
|
||||
const SelectFieldClass = {
|
||||
control: (state: any) =>
|
||||
state.isFocused
|
||||
? `select focused ${icon && "with-icon"} ${rounded && "rounded-full"}`
|
||||
: `select ${icon && "with-icon"} ${rounded && "rounded-full"}`,
|
||||
option: (state: any) =>
|
||||
state.isFocused ? "select-option" : "select-option",
|
||||
input: (state: any) => (state.isFocused ? "select-input" : "select-input"),
|
||||
placeholder: (state: any) =>
|
||||
state.isFocused ? "select-placeholder" : "select-placeholder",
|
||||
singleValue: (state: any) =>
|
||||
state.isFocused ? "select-value" : "select-value",
|
||||
menu: (state: any) =>
|
||||
state.isFocused ? "select-container" : "select-container",
|
||||
indicatorSeparator: (state: any) =>
|
||||
state.isFocused ? "select-separator" : "select-separator",
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
{label && <label className="sub-title">{label}</label>}
|
||||
|
||||
<div className={`form-group ${icon ? "input-icon" : ""}`}>
|
||||
{icon && (
|
||||
<FontAwesomeIcon icon={icon} className="form-control-feedback" />
|
||||
)}
|
||||
<div className="w-100">
|
||||
<ReactSelect
|
||||
classNamePrefix="select"
|
||||
classNames={SelectFieldClass}
|
||||
{...rest}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -440,7 +440,7 @@ styles with important tags:
|
||||
.form-control-feedback {
|
||||
position: absolute;
|
||||
z-index: 2;
|
||||
width: 2.375rem;
|
||||
width: 2.75rem;
|
||||
// height: 2.375rem;
|
||||
// line-height: 2.69rem;
|
||||
text-align: center;
|
||||
@@ -759,7 +759,7 @@ styles with important tags:
|
||||
padding-left: 2.25rem;
|
||||
padding-right: 0.5rem;
|
||||
background-color: $input-dark;
|
||||
border-radius: 50px;
|
||||
border-radius: 0.5rem;
|
||||
border-color: $input-dark !important;
|
||||
box-shadow: none;
|
||||
cursor: pointer;
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import React from "react";
|
||||
import { SessionWrapper } from "@storyteller/components/src/session/SessionWrapper";
|
||||
import { useParams } from "react-router-dom";
|
||||
import Input from "components/common/Input/Input";
|
||||
import { Input, TextArea, Select } from "components/common/Input/Input";
|
||||
import Panel from "components/common/Panel/Panel";
|
||||
import { faUser } from "@fortawesome/pro-solid-svg-icons";
|
||||
import { faEye, faFilePen } from "@fortawesome/pro-solid-svg-icons";
|
||||
import PageHeaderModelView from "components/layout/PageHeaderModelView/PageHeaderModelView";
|
||||
|
||||
interface VcModelEditPageProps {
|
||||
sessionWrapper: SessionWrapper;
|
||||
@@ -13,18 +14,49 @@ const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
console.log(event.target.value);
|
||||
};
|
||||
|
||||
const savebtn = <button className="btn btn-primary">Save Changes</button>;
|
||||
|
||||
const visibility = [
|
||||
{ value: "public", label: "Public" },
|
||||
{ value: "hidden", label: "Hidden" },
|
||||
];
|
||||
|
||||
export default function VcModelEditPage(props: VcModelEditPageProps) {
|
||||
let { token } = useParams() as { token: string };
|
||||
return (
|
||||
<div>
|
||||
<PageHeaderModelView
|
||||
title="Solid Snake"
|
||||
subText="Solid Snake"
|
||||
view="edit"
|
||||
titleIcon={faFilePen}
|
||||
extras={savebtn}
|
||||
modelType="V2V"
|
||||
/>
|
||||
|
||||
<Panel padding>
|
||||
<Input
|
||||
label="Username"
|
||||
type="text"
|
||||
placeholder="Username"
|
||||
icon={faUser}
|
||||
onChange={handleChange}
|
||||
/>
|
||||
<div className="d-flex flex-column gap-4">
|
||||
<Input
|
||||
label="Name"
|
||||
type="text"
|
||||
placeholder="Model title"
|
||||
onChange={handleChange}
|
||||
/>
|
||||
|
||||
<TextArea
|
||||
rows={3}
|
||||
label="Description"
|
||||
placeholder="Description"
|
||||
onChange={() => {}}
|
||||
/>
|
||||
|
||||
<Select
|
||||
icon={faEye}
|
||||
defaultValue={visibility[0]}
|
||||
options={visibility}
|
||||
label="Visibility"
|
||||
/>
|
||||
</div>
|
||||
</Panel>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user