Normalize buttons position for cards and modals, and fix cards first and last elements position.

This commit is contained in:
Madeorsk 2024-07-14 18:22:13 +02:00
parent 141748b34a
commit b0e71f9257
Signed by: Madeorsk
SSH key fingerprint: SHA256:J9G0ofIOLKf7kyS2IfrMqtMaPdfsk1W02+oGueZzDDU
5 changed files with 52 additions and 18 deletions

View file

@ -32,6 +32,7 @@ import {DemoCurtain} from "./DemoCurtain";
import {DemoModal} from "./DemoModal"; import {DemoModal} from "./DemoModal";
import {useCallableModal} from "../src/Components/Modals/Modals"; import {useCallableModal} from "../src/Components/Modals/Modals";
import {ModalType} from "../src/Components/Modals/ModalsTypes"; import {ModalType} from "../src/Components/Modals/ModalsTypes";
import {Buttons} from "../src/Components/Buttons/Buttons";
export function DemoApp() export function DemoApp()
{ {
@ -245,8 +246,10 @@ export function DemoApp()
egestas, leo lorem malesuada felis, eu imperdiet orci magna ultrices est. egestas, leo lorem malesuada felis, eu imperdiet orci magna ultrices est.
</p> </p>
<Buttons>
<button type={"button"}>Button position ?</button> <button type={"button"}>Button position ?</button>
<button type={"button"}>Button position ?</button> <button type={"button"}>Button position ?</button>
</Buttons>
</Card> </Card>
<Card> <Card>

View file

@ -1,6 +1,7 @@
import React from "react"; import React from "react";
import {Modal, useModal} from "../src/Components/Modals/Modals"; import {Modal, useModal} from "../src/Components/Modals/Modals";
import {ModalType} from "../src/Components/Modals/ModalsTypes"; import {ModalType} from "../src/Components/Modals/ModalsTypes";
import {Buttons} from "../src/Components/Buttons/Buttons";
export function DemoModal({type}: { type: ModalType; }) export function DemoModal({type}: { type: ModalType; })
{ {
@ -10,7 +11,9 @@ export function DemoModal({type}: { type: ModalType; })
<Modal type={type} title={"Modal title"}> <Modal type={type} title={"Modal title"}>
Modal test content Modal test content
<Buttons>
<button onClick={close}>OK</button> <button onClick={close}>OK</button>
</Buttons>
</Modal> </Modal>
); );
} }

View file

@ -0,0 +1,16 @@
import React from "react";
import {classes} from "../../Utils";
export function Buttons({placement, children}: React.PropsWithChildren<{
placement?: "right"|"left"|"center";
}>)
{
// Default placement: right.
placement = placement ?? "right";
return (
<div className={classes("buttons", placement)}>
{children}
</div>
);
}

View file

@ -168,3 +168,30 @@ a.button, button, input[type="submit"], input[type="reset"]
margin-right: 0.05em; margin-right: 0.05em;
} }
} }
div.buttons
{
display: flex;
flex-direction: row;
gap: 0.5em;
margin: 0.25em auto;
&.right
{
justify-content: flex-end;
}
&.left
{
justify-content: flex-start;
}
&.center
{
justify-content: center;
}
button, .button
{
margin: 0;
}
}

View file

@ -15,21 +15,6 @@
margin: 0.33em 0 0.5em 0; margin: 0.33em 0 0.5em 0;
} }
button
{
display: block;
margin-left: auto;
}
> :first-child
{
margin-top: 0;
}
> :last-child
{
margin-bottom: 0;
}
&.floating &.floating
{ {
width: 20em; width: 20em;