fix: initial grid improvements

pull/106/head
corpulent 3 years ago
parent e2eb174095
commit acb987cf60

@ -7,56 +7,98 @@ const Root = styled("div")`
display: flex; display: flex;
flex-direction: column; flex-direction: column;
row-gap: ${({ theme }) => theme.spacing(1)}; row-gap: ${({ theme }) => theme.spacing(1)};
@media (max-width: 640px) {
row-gap: 0;
}
`; `;
const Group = styled("div")` const Group = styled("div")`
display: flex; display: grid;
flex-direction: row; grid-template-columns: repeat(3, 1fr);
grid-column-gap: 0px;
grid-row-gap: 0px;
@media (max-width: 640px) { @media (max-width: 640px) {
flex-direction: column; grid-template-columns: repeat(1, 1fr);
} }
column-gap: ${({ theme }) => theme.spacing(1)}; column-gap: ${({ theme }) => theme.spacing(1)};
width: 100%; width: 100%;
`; `;
const SpanTwo = styled("div")`
grid-column: span 2;
@media (max-width: 640px) {
grid-column: span 3;
}
`;
const General = () => { const General = () => {
return ( return (
<Root> <Root>
<TextField label="Service name" name="serviceName" required={true} /> <Group>
<TextField label="Service name" name="serviceName" required={true} />
</Group>
<Group> <Group>
<TextField label="Image name" name="imageName" required={false} /> <TextField label="Image name" name="imageName" required={false} />
<TextField label="Image tag" name="imageTag" /> <TextField label="Image tag" name="imageTag" />
</Group> </Group>
<TextField label="Container name" name="containerName" required={false} /> <Group>
<TextField label="Command" name="command" required={false} /> <TextField
<TextField label="Entrypoint" name="entrypoint" required={false} /> label="Container name"
<TextField label="Env file" name="envFile" required={false} /> name="containerName"
<TextField label="Working directory" name="workingDir" required={false} /> required={false}
/>
</Group>
<Toggle <Group>
name="restart" <TextField label="Command" name="command" required={false} />
label="Restart policy" </Group>
options={[
{ <Group>
value: "no", <TextField label="Entrypoint" name="entrypoint" required={false} />
text: "no" </Group>
},
{ <Group>
value: "always", <TextField label="Env file" name="envFile" required={false} />
text: "always" </Group>
},
{ <Group>
value: "on-failure", <SpanTwo>
text: "on-failure" <TextField
}, label="Working directory"
{ name="workingDir"
value: "unless-stopped", required={false}
text: "unless-stopped" />
} </SpanTwo>
]} </Group>
/>
<Group>
<SpanTwo>
<Toggle
name="restart"
label="Restart policy"
options={[
{
value: "no",
text: "no"
},
{
value: "always",
text: "always"
},
{
value: "on-failure",
text: "on-failure"
},
{
value: "unless-stopped",
text: "unless-stopped"
}
]}
/>
</SpanTwo>
</Group>
<Records <Records
name="ports" name="ports"

@ -118,14 +118,16 @@ const Record: FunctionComponent<IRecordProps> = (
)) ))
)} )}
{renderRemoveWrapper( {renderRemoveWrapper(
<RemoveButton <div className="flex justify-end content-end">
variant="soft" <RemoveButton
size="sm" variant="soft"
color="danger" size="sm"
onClick={handleRemove} color="danger"
> onClick={handleRemove}
<MinusSmIcon className="h-5 w-5" /> >
</RemoveButton> <MinusSmIcon className="h-5 w-5" />
</RemoveButton>
</div>
)} )}
</Root> </Root>
); );

@ -37,6 +37,9 @@ const Group = styled("div", {
align-items: ${({ empty }) => (empty ? "center" : "flex-end")}; align-items: ${({ empty }) => (empty ? "center" : "flex-end")};
row-gap: ${({ theme }) => theme.spacing(1)}; row-gap: ${({ theme }) => theme.spacing(1)};
width: 100%; width: 100%;
@media (max-width: 640px) {
row-gap: 0;
}
`; `;
const GroupTitle = styled("h5")` const GroupTitle = styled("h5")`
@ -58,7 +61,6 @@ const RecordList = styled("div")`
`; `;
const AddButton = styled(IconButton)` const AddButton = styled(IconButton)`
margin-top: ${({ theme }) => theme.spacing(1)};
border-radius: ${({ theme }) => theme.spacing(2)}; border-radius: ${({ theme }) => theme.spacing(2)};
`; `;

@ -9,11 +9,7 @@ export interface ITextFieldProps {
[key: string]: any; [key: string]: any;
} }
const Root = styled("div")` const Root = styled("div")``;
display: flex;
flex-direction: column;
width: 100%;
`;
const TextField: FunctionComponent<ITextFieldProps> = ( const TextField: FunctionComponent<ITextFieldProps> = (
props: ITextFieldProps props: ITextFieldProps
@ -25,28 +21,30 @@ const TextField: FunctionComponent<ITextFieldProps> = (
return ( return (
<Root> <Root>
{label && ( <div>
<label htmlFor={name} className="lbl-util"> {label && (
{label + (required ? "*" : "")} <label htmlFor={name} className="lbl-util">
</label> {label + (required ? "*" : "")}
)} </label>
)}
<input <input
id={name} id={name}
name={name} name={name}
type="text" type="text"
autoComplete="off" autoComplete="off"
className="input-util" className="input-util mb-2 sm:mb-0"
required={required} required={required}
onBlur={formik.handleBlur} onBlur={formik.handleBlur}
onChange={formik.handleChange} onChange={formik.handleChange}
value={lodash.get(formik.values, name)} value={lodash.get(formik.values, name)}
{...otherProps} {...otherProps}
/> />
<div className="mt-1 text-xs text-red-600"> <div className="text-xs text-red-600">
{error && <span className="caption">{error}</span>} {error && <span className="caption">{error}</span>}
{!error && help} {!error && help}
</div>
</div> </div>
</Root> </Root>
); );

@ -1,6 +1,6 @@
import lodash from "lodash"; import lodash from "lodash";
import { useFormikContext } from "formik"; import { useFormikContext } from "formik";
import { Fragment, FunctionComponent, ReactElement, useCallback } from "react"; import { Fragment, FunctionComponent, ReactElement } from "react";
import { Button, styled } from "@mui/joy"; import { Button, styled } from "@mui/joy";
export interface IToggleProps { export interface IToggleProps {
@ -25,16 +25,21 @@ const Root = styled("div")`
`; `;
const Label = styled("label")` const Label = styled("label")`
margin-bottom: 0.25rem;
display: block;
font-size: 0.75rem;
line-height: 1rem;
font-weight: 700;
color: #374151; color: #374151;
font-size: 12px;
font-weight: 500;
padding: 0; padding: 0;
margin: 0;
`; `;
const Buttons = styled("div")` const Buttons = styled("div")`
display: flex; display: flex;
flex-direction: row; flex-direction: row;
@media (max-width: 640px) {
margin-bottom: 0.5rem;
}
`; `;
const ToggleButton = styled(Button)<IToggleButtonProps>(({ index, total }) => ({ const ToggleButton = styled(Button)<IToggleButtonProps>(({ index, total }) => ({
@ -44,8 +49,7 @@ const ToggleButton = styled(Button)<IToggleButtonProps>(({ index, total }) => ({
${index === total - 1 ? "8px" : "0px"} ${index === total - 1 ? "8px" : "0px"}
${index === 0 ? "8px" : "0px"} ${index === 0 ? "8px" : "0px"}
`, `,
fontSize: 11, fontSize: 11
minWidth: 120
})); }));
const ButtonBorder = styled("div")` const ButtonBorder = styled("div")`

Loading…
Cancel
Save