Skip to content

Commit aa5bdd9

Browse files
committedFeb 5, 2025
feat(modal): Refactored modal dialog and improved styling
1 parent abbd01e commit aa5bdd9

24 files changed

+471
-163
lines changed
 

‎.eslintrc.cjs

+11
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,16 @@ module.exports = {
1515
'max-len': ['error', { code: 120 }],
1616
'no-console': ['error'],
1717
'no-debugger': ['error'],
18+
'no-unused-vars': 'off',
19+
'@typescript-eslint/no-unused-vars': [
20+
'error',
21+
{
22+
args: 'all',
23+
argsIgnorePattern: '^_',
24+
destructuredArrayIgnorePattern: '^_',
25+
varsIgnorePattern: '^_',
26+
ignoreRestSiblings: true,
27+
},
28+
],
1829
},
1930
};

‎apps/solid/src/routes/dialog.route.tsx

+15-5
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ import {
33
Container,
44
Divider,
55
Heading,
6-
Dialog,
7-
ConfirmDialog,
8-
DialogContainer,
6+
ModalDialog,
7+
ConfirmModal,
8+
ModalPortal,
99
} from '@spuxx/solid';
1010
import { Component } from 'solid-js';
1111

1212
export const DialogRoute: Component = () => {
1313
return (
1414
<Container tag="article">
15-
<DialogContainer />
15+
<ModalPortal />
1616

1717
<Heading level={1}>Dialog</Heading>
1818
<Divider color="gradient" />
@@ -21,7 +21,17 @@ export const DialogRoute: Component = () => {
2121
<Divider color="gradient" />
2222
<Button
2323
onClick={() => {
24-
Dialog.show(ConfirmDialog, {});
24+
ModalDialog.show(ConfirmModal, {
25+
title: 'Hello World!',
26+
color: 'gradient',
27+
content: 'This is a confirm dialog.',
28+
confirmLabel: 'Confirm',
29+
confirmIcon: 'mdi:check',
30+
// confirmColor: 'gradient',
31+
cancelLabel: 'Cancel',
32+
// cancelColor: 'gradient',
33+
size: 'medium',
34+
});
2535
}}
2636
>
2737
Open Confirm Dialog

‎packages/browser-utils/src/styles.css

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
@import './styles/variables.css';
22
@import './styles/application.css';
33
@import './styles/components.css';
4+
@import './styles/modal.css';
45
@import './styles/variants.css';
56
@import './styles/colors.css';
7+
@import './styles/animations.css';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
@keyframes enter {
2+
0% {
3+
opacity: 0;
4+
scale: 0.95;
5+
transform: translate(-50%, calc(-50% + 8px)) scale(0.95);
6+
}
7+
}
8+
9+
@keyframes exit {
10+
to {
11+
opacity: 0;
12+
scale: 0.95;
13+
transform: translate(-50%, calc(-50% + 8px)) scale(0.95);
14+
}
15+
}

‎packages/browser-utils/src/styles/colors.css

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
}
2626

2727
.spx[spx-variant='colored'].spx[spx-color='warning'] {
28-
color: var(--sp-color-warning);
28+
color: var(--spx-color-warning);
2929
}
3030

3131
.spx[spx-variant='colored'].spx[spx-color='error'] {
@@ -71,7 +71,7 @@
7171
}
7272

7373
.spx[spx-variant='contained'].spx[spx-color='warning'] {
74-
background: var(--sp-color-warning);
74+
background: var(--spx-color-warning);
7575
color: var(--spx-color-on-warning);
7676
}
7777

@@ -112,8 +112,8 @@
112112
}
113113

114114
.spx[spx-variant='outlined'].spx[spx-color='warning'] {
115-
border-color: var(--sp-color-warning);
116-
color: var(--sp-color-warning);
115+
border-color: var(--spx-color-warning);
116+
color: var(--spx-color-warning);
117117
}
118118

119119
.spx[spx-variant='outlined'].spx[spx-color='error'] {

‎packages/browser-utils/src/styles/components/input/button.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
}
1919

2020
iconify-icon {
21-
font-size: large;
21+
font-size: larger;
2222
}
2323
}
2424

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
.spx-modal-overlay {
2+
position: absolute;
3+
top: 0;
4+
left: 0;
5+
width: 100%;
6+
height: 100%;
7+
background-color: rgba(0, 0, 0, 0.5);
8+
}
9+
10+
.spx-modal {
11+
position: absolute;
12+
top: 50%;
13+
left: 50%;
14+
transform: translate(-50%, -50%);
15+
background-color: var(--spx-color-dialog);
16+
color: var(--spx-color-on-dialog);
17+
border-radius: var(--spx-border-radius);
18+
width: fit-content;
19+
max-width: 80svw;
20+
}
21+
22+
.spx-modal[data-open] {
23+
animation: enter 150ms ease;
24+
}
25+
26+
.spx-modal[data-closed] {
27+
animation: exit 150ms ease;
28+
}
29+
30+
.spx-modal[data-size='small'] {
31+
width: 400px;
32+
}
33+
34+
.spx-modal[data-size='medium'] {
35+
width: 600px;
36+
}
37+
38+
.spx-modal[data-size='large'] {
39+
width: 1000px;
40+
}
41+
42+
.spx-modal[data-size='auto'] {
43+
width: fit-content;
44+
}
45+
46+
.spx-modal[data-size='full'] {
47+
width: 100%;
48+
}
49+
50+
.spx-modal-header {
51+
display: flex;
52+
align-items: center;
53+
justify-content: space-between;
54+
padding: 0.5rem;
55+
border-bottom-left-radius: 0px !important;
56+
border-bottom-right-radius: 0px !important;
57+
58+
h2 {
59+
margin: 0;
60+
padding-left: 1rem;
61+
}
62+
63+
.spx-button {
64+
background: none;
65+
}
66+
}
67+
68+
.spx-modal-body {
69+
margin: 1rem 0;
70+
padding: 0rem 1.5rem;
71+
}
72+
73+
.spx-modal-footer {
74+
display: flex;
75+
flex-direction: row;
76+
justify-content: end;
77+
align-items: center;
78+
padding: 0.5rem;
79+
gap: 0.5rem;
80+
}

‎packages/browser-utils/src/themes/default.theme.css

+6-2
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ html *,
1717
--spx-color-surface: #3f3f46;
1818
--spx-color-on-surface: var(--spx-color-text-default);
1919
--spx-color-primary: #0d9488;
20-
--spx-color-on-primary: var(--spx-color-text-default);
20+
--spx-color-on-primary: var(--spx-color-text-highlighted);
2121
--spx-color-secondary: #3f3f46;
2222
--spx-color-on-secondary: var(--spx-color-text-default);
2323
--spx-color-gradient: linear-gradient(45deg, var(--spx-color-primary), #a21caf);
24-
--spx-color-on-gradient: var(--spx-color-text-default);
24+
--spx-color-on-gradient: var(--spx-color-text-highlighted);
2525

2626
/* Status Colors */
2727
--spx-color-info: #166534;
@@ -33,6 +33,10 @@ html *,
3333
--spx-color-error: #b91c1c;
3434
--spx-color-on-error: var(--spx-color-text-default);
3535

36+
/* Dialog */
37+
--spx-color-dialog: var(--spx-color-surface);
38+
--spx-color-on-dialog: var(--spx-color-on-surface);
39+
3640
/* Filters */
3741
--spx-filter-control-hover: brightness(1.25);
3842
--spx-filter-control-hover-contained: brightness(0.8);

‎packages/browser-utils/src/types/public/index.ts

+15
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,18 @@ export const ContentColor = {
3131
* The content color of an element.
3232
*/
3333
export type ContentColor = (typeof ContentColor)[keyof typeof ContentColor];
34+
35+
/**
36+
* The size of a modal dialog.
37+
*/
38+
export const ModalSize = {
39+
small: 'small',
40+
medium: 'medium',
41+
large: 'large',
42+
auto: 'auto',
43+
max: 'max',
44+
};
45+
/**
46+
* The size of a modal dialog.
47+
*/
48+
export type ModalSize = (typeof ModalSize)[keyof typeof ModalSize];

‎packages/solid/src/dialog/built-in/confirm.dialog.tsx

-19
This file was deleted.

‎packages/solid/src/dialog/dialog-container.component.tsx

-54
This file was deleted.

‎packages/solid/src/dialog/dialog.service.ts

-38
This file was deleted.

‎packages/solid/src/dialog/dialog.types.ts

-35
This file was deleted.

‎packages/solid/src/dialog/index.ts

-4
This file was deleted.

0 commit comments

Comments
 (0)