Skip to content

Commit

Permalink
Add dialog component (#90)
Browse files Browse the repository at this point in the history
* Add dialog component

* Update card styling in card panels

* Update DID modal

* update credential modal

* update issuance modal

* Add readonly styling to textarea

* Update radio styling
  • Loading branch information
kirahsapong authored Jul 13, 2023
1 parent 08f70a1 commit 3060be4
Show file tree
Hide file tree
Showing 12 changed files with 377 additions and 279 deletions.
26 changes: 17 additions & 9 deletions src/App.scss
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,10 @@ textarea {
line-height: 2;
tab-size: 2;
resize: none;

&[readonly] {
opacity: 0.5;
}
}

select:hover,
Expand All @@ -349,15 +353,20 @@ textarea:focus:not([readonly]) {
fieldset {
border: none;
padding: 0;
margin: 0.5rem 0 1.5rem;
display: inline-flex;
width: 100%;
}

legend {
margin-bottom: 0.5rem;
legend {
margin-bottom: 0.5rem;
padding-inline: 0;
}

.radio-card-options {
margin-top: 1rem;
display: flex;
}
}


.radio-container {
position: relative;

Expand All @@ -372,14 +381,13 @@ legend {
}

input[type="radio"] ~ label {
padding: 2px 10px;
padding: 1rem 2rem;
border-radius: var(--radius-sm);
font-size: var(--font-sm);
background-color: var(--grey-10);
border: 1px solid var(--grey-30);
color: var(--grey-50);
text-align: center;
padding-inline: 1rem;
margin-right: 0.5rem;

.radio-control-content {
Expand All @@ -396,8 +404,8 @@ legend {
}

input[type="radio"]:checked ~ label {
background-color: var(--grey-30);
border: 1px solid var(--color-white);
background-color: var(--grey-10);
border: 2px solid var(--color-yellow);
color: var(--color-white);

p {
Expand Down
210 changes: 210 additions & 0 deletions src/components/Dialog/Dialog.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
.dialog-component {

.dialog {
background: var(--grey-5);
border: 1px solid var(--grey-10);
color: var(--color-white);
box-shadow: 0 10px 20px var(--color-black);
max-width: 100%;
height: calc(100% - 2rem);
margin-block: auto;
padding: 0;
border-radius: var(--radius-sm);
overflow: hidden;
width: max-content;

&::backdrop {
background: rgba(6,6,6,0.9);
}

&-header {
background: var(--grey-5);
border-bottom: 1px solid var(--grey-10);
padding: 1rem;
position: sticky;
top: 0;
z-index: 1;
margin-block-end: 1rem;

button {
.icon-container > svg {
width: 24px;
}
}
}

&-heading {

h2 {
font-size: 1.5rem;
padding-inline-end: 35%;
letter-spacing: 1px;
}

p {
font-size: 1rem;
padding-inline-end: 12.5%;
margin-bottom: 2rem;
border-bottom: 1px solid var(--grey-15);
letter-spacing: 0.5px;
padding-bottom: 1rem;
line-height: 1.75;
}

}

details {
background: var(--grey-15);
border-radius: var(--radius-sm);

summary {
padding: 1rem;
display: flex;
justify-content: space-between;

&:hover {
cursor: pointer;
}

.icon-container {
transition: 0.15s ease transform;
}
}

&[open] summary .icon-container {
transform: rotate(-180deg);
}

.field-container {
border-top: 1px solid var(--grey-20);
border-radius: 0;
margin: 0;

a {
margin-top: 0.5rem;
font-size: var(--font-xs);
}
}

textarea::placeholder {
font-style: italic;
}
}

.field-container {
background: var(--grey-15);
padding: 1rem;
margin-block: 1rem;
border-radius: var(--radius-sm);
}

&-body {
display: flex;
flex-wrap: wrap;
position: relative;
justify-content: center;
min-height: calc(100% - 4rem);
padding: 2rem;
overflow: scroll;
max-height: 100%;

.modal-input-note {
font-size: var(--font-xs);
margin-block: 0.125rem 0.25rem;
}

.dialog-art {
display: flex;
align-items: center;
justify-content: center;
flex: auto;
margin-inline: 1rem;
height: 580px;
position: sticky;
top: 0;
display: none;

.dialog-background {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
background: linear-gradient(to bottom, #161616, #000000);
border-radius: var(--radius-md);
filter: blur(20px);
z-index: -1;
}

}

form {
margin-inline: 2rem;
background: var(--grey-10);
padding: 2rem;
border-radius: var(--radius-sm);
width: 100%;
max-width: 680px;
margin-block-end: 4rem;

.banner {
padding: 1rem;
margin-block-end: 1rem;
display: flex;
gap: 8px;

&-danger {
border: 1px solid var(--color-red);
background: var(--red-20);

.icon-container {
color: var(--color-red);
}
}

&-success {
border: 1px solid var(--color-green);
background: var(--green-20);

.icon-container {
color: var(--color-green);
}
}

&-warn {
border: 1px solid var(--color-orange);
background: var(--orange-20);

.icon-container {
color: var(--color-orange);
}
}
}

.button-row {
margin-block: 2rem 1rem;
justify-content: flex-end;
}
}
}
}

@media screen and (max-width: 997px) {
.dialog {
height: 100%;
max-height: 100%;
margin: 0;
}

.dialog-body {
padding: 0;

form {
margin-inline: 0;
background: var(--grey-5);
padding-block-start: 0;
margin-block-start: 0;
}
}
}
}
46 changes: 46 additions & 0 deletions src/components/Dialog/Dialog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import Icon, { XCross } from "@/icons/Icon";
import { Component, createEffect } from "solid-js";
import "./Dialog.scss";

const Dialog: Component<{content, afterCloseModal, handleSubmit, children}> = (props) => {
let dialog;

const showModal = () => {
dialog.showModal();
document.body.classList.add('no-scroll');
dialog.addEventListener('close', () => {
document.body.classList.remove('no-scroll');
props.afterCloseModal();
});
}

const closeModal = () => {
return dialog.close();
}

return (
<div class="dialog-component">
<button class={props.content.button.className} disabled={props.content.button.disabled} onclick={showModal}>
{props.content.button.label}
</button>
<dialog class="dialog" ref={dialog}>
<div class="dialog-header">
<button title="Close dialog" onClick={closeModal}>
<Icon svg={XCross} />
</button>
</div>
<div class="dialog-body">
<form onSubmit={props.handleSubmit}>
<div class="dialog-heading">
<h2>{props.content.heading.h2}</h2>
{props.content.heading.p && <p>{props.content.heading.p}</p>}
</div>
{props.children}
</form>
</div>
</dialog>
</div>
)
}

export default Dialog;
48 changes: 26 additions & 22 deletions src/components/RadioCardSet/RadioCardSet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,33 @@ import { Component, For, JSX } from "solid-js";
activeSelection?
}> = (props) => {
return (
<fieldset class="radio-card-set field-container">
<legend class="field-heading">
<label>{props.legend} {props.optional && "(Optional)"}</label>
</legend>
{props.description && <p class="modal-input-note">{props.description}</p>}
<For each={props.options}>
{(option) =>
<div class="radio-container">
<input required={!props.optional} checked={option.value === props.activeSelection} oninput={props.handleEvent} type="radio" name={props.name} id={option.value} value={option.value} disabled={option.disabled}/>
<label for={option.value} class="radio-control">
<div class="radio-control-content">
{option.imageSrc && <img class="radio-card-image" src={option.imageSrc} alt="" />}
<div class="radio-control-body">
<p class="radio-control-heading">{option.label}</p>
{option.description && <p class="radio-card-description">{option.description}</p>}
{option.footerLabel && <p class="radio-control-footer-label">{option.footerLabel}</p>}
</div>
<div class="field-container">
<fieldset class="radio-card-set">
<legend class="field-heading">
<label>{props.legend} {props.optional && "(Optional)"}</label>
</legend>
{props.description && <p class="modal-input-note">{props.description}</p>}
<div class="radio-card-options">
<For each={props.options}>
{(option) =>
<div class="radio-container">
<input required={!props.optional} checked={option.value === props.activeSelection} oninput={props.handleEvent} type="radio" name={props.name} id={option.value} value={option.value} disabled={option.disabled}/>
<label for={option.value} class="radio-control">
<div class="radio-control-content">
{option.imageSrc && <img class="radio-card-image" src={option.imageSrc} alt="" />}
<div class="radio-control-body">
<p class="radio-control-heading">{option.label}</p>
{option.description && <p class="radio-card-description">{option.description}</p>}
{option.footerLabel && <p class="radio-control-footer-label">{option.footerLabel}</p>}
</div>
</div>
</label>
</div>
</label>
</div>
}
</For>
</fieldset>
}
</For>
</div>
</fieldset>
</div>

)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@
flex-direction: column;
text-align: center;
min-height: 250px;
height: 100%;
width: 100%;

svg {
width: 36px;
Expand Down
Loading

0 comments on commit 3060be4

Please sign in to comment.