apps/web: fix layout

This commit is contained in:
vchikalkin 2023-11-23 17:06:58 +03:00
parent c497890bcc
commit 39c13e9422
10 changed files with 71 additions and 71 deletions

View File

@ -52,10 +52,10 @@ export default function RootLayout({ children }: { readonly children: React.Reac
<Logo />
<Auth />
</Header>
<div className="flex flex-col items-center ">
<Content>
<Controls />
<Content>{children}</Content>
</div>
{children}
</Content>
</body>
</html>
);

View File

@ -8,7 +8,7 @@ export function Conditions({ html }: Props) {
return (
<Background
dangerouslySetInnerHTML={{ __html: html }}
className="lg:w-standard grid w-full justify-center p-5 font-[calibri]"
className="grid w-full justify-center p-5 font-[calibri]"
/>
);
}

View File

@ -15,17 +15,16 @@ function compatMetadata(metaData: Props['metaData']) {
return metaData;
}
export function Elements({ data, metaData }: Props) {
const { init, setValue, validation, values } = useFormStore();
useEffect(() => {
init(data);
}, [data, init]);
return (
<div className="mt-2 grid auto-rows-auto grid-cols-1 gap-2 gap-x-4 md:grid-cols-2 lg:grid-cols-3">
{Object.keys(compatMetadata(metaData)).map((name) => {
const { fieldType, label, max, min = 0, visible, ...props } = metaData[name];
function RenderElement({
fieldType,
label,
max,
min = 0,
name,
visible,
...props
}: Props['metaData'][number] & { readonly name: string }) {
const { setValue, validation, values } = useFormStore();
if (!visible) return false;
@ -33,7 +32,6 @@ export function Elements({ data, metaData }: Props) {
return (
<ElementContainer
classNameParent={fieldType === 'TEXTAREA' ? 'col-[span_3]' : undefined}
intent={validation[name] ? 'danger' : 'default'}
message={validation[name]?.message}
key={name}
@ -57,7 +55,25 @@ export function Elements({ data, metaData }: Props) {
/>
</ElementContainer>
);
})}
}
export function Elements({ data, metaData }: Props) {
const { init } = useFormStore();
useEffect(() => {
init(data);
}, [data, init]);
const { comment, ...meta } = compatMetadata(metaData);
return (
<>
<div className="mt-2 grid gap-2 gap-x-4 md:grid md:grid-cols-2 lg:grid-cols-3">
{Object.keys(meta).map((name) => (
<RenderElement key={name} {...metaData[name]} name={name} />
))}
</div>
<RenderElement {...comment} name="comment" />
</>
);
}

View File

@ -3,7 +3,7 @@ import { Heading } from 'ui';
export function Header({ link, title }: { readonly link: string; readonly title: string }) {
return (
<div className="flex justify-between">
<div className="flex flex-col justify-between md:flex-row">
<Heading size={2}>{title}</Heading>
<Link href={link} className="text-primary-600 text-sm font-medium hover:underline" prefetch>
Посмотреть условия

View File

@ -7,7 +7,7 @@ import { Background, LoadingSpinner } from 'ui';
function OverlayWrapper({ children }: PropsWithChildren) {
return (
<Background className="lg:w-standard absolute grid h-full w-full items-center justify-center border-none bg-opacity-80 backdrop-blur-sm">
<Background className="absolute grid h-full w-full items-center justify-center border-none bg-opacity-80 backdrop-blur-sm">
<div className="flex flex-row items-center gap-2">{children} </div>
</Background>
);

View File

@ -15,7 +15,7 @@ function Content(props: Props) {
const { pageUrlParams } = useContext(FormContext);
return (
<Background className="lg:w-standard relative grid w-full gap-2 p-5">
<Background className="flex w-full flex-col gap-2 p-5">
<Overlay />
<Header title={title} link={'/ius' + createUrl({ ...pageUrlParams, route: '/conditions' })} />
<Elements {...props} />

View File

@ -6,7 +6,7 @@ export function Controls() {
const router = useRouter();
return (
<div className="lg:w-standard flex w-full flex-row px-5 pt-5">
<div className="flex w-full flex-row px-5 pt-5">
<button
className="flex flex-row items-center gap-2 text-sm"
type="button"

View File

@ -5,9 +5,7 @@ import { forwardRef, type HTMLAttributes, type PropsWithChildren } from 'react';
export type ContainerProps = HTMLAttributes<HTMLDivElement> & PropsWithChildren;
const parentVariants = cva('flex flex-col justify-center');
const variants = cva('min-h-[36px] flex items-center', {
const variants = cva('flex min-h-[36px] items-center', {
defaultVariants: {
intent: 'default',
},
@ -20,28 +18,11 @@ const variants = cva('min-h-[36px] flex items-center', {
});
export type WrapperProps = HTMLAttributes<HTMLDivElement> &
VariantProps<typeof variants> & { readonly classNameParent?: string; readonly message?: string };
VariantProps<typeof variants> & { readonly message?: string };
export const ElementContainer = forwardRef<HTMLDivElement, WrapperProps>(
(
{
children,
className,
classNameParent,
id,
intent,
message = 'Некорректные данные',
title,
...props
},
ref
) => (
<div
{...props}
className={cn(parentVariants({ className: classNameParent }))}
ref={ref}
{...props}
>
({ children, className, id, intent, message = 'Некорректные данные', title, ...props }, ref) => (
<div {...props} className="flex flex-col justify-center" ref={ref} {...props}>
<label
htmlFor={id}
className="mb-1 block overflow-hidden overflow-ellipsis whitespace-nowrap text-sm font-medium text-black text-opacity-90"

View File

@ -1,5 +1,9 @@
import type { PropsWithChildren } from 'react';
export function Content({ children }: PropsWithChildren) {
return <div className="flex w-full justify-center gap-2 py-5">{children}</div>;
return (
<div className="grid w-full place-items-center">
<div className="xl:w-standard grid w-screen gap-5">{children}</div>
</div>
);
}

View File

@ -6,7 +6,7 @@ import { forwardRef } from 'react';
const variants = cva('font-bold leading-7 text-gray-900 sm:truncate sm:tracking-tight', {
defaultVariants: {
size: 'default',
size: 1,
},
variants: {
size: {
@ -19,7 +19,6 @@ const variants = cva('font-bold leading-7 text-gray-900 sm:truncate sm:tracking-
7: 'text-6xl sm:text-7xl',
8: 'text-7xl sm:text-8xl',
9: 'text-8xl sm:text-9xl',
default: 'text-lg',
},
},
});