-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(modal): update modal to follow best practices (#292)
* add new utilities * rewrite modal component * update modal
- Loading branch information
Showing
11 changed files
with
668 additions
and
255 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export const Slots = { | ||
IMAGE: "image", | ||
ACTION_BAR: "action-bar", | ||
} as const; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { BaseEvent } from "../utils"; | ||
|
||
export class HideEvent extends BaseEvent<null> { | ||
public static type = "hide"; | ||
|
||
constructor() { | ||
super(HideEvent.type, { | ||
composed: true, | ||
cancelable: true, | ||
details: null, | ||
}); | ||
} | ||
} | ||
|
||
export class ShowEvent extends BaseEvent<null> { | ||
public static type = "show"; | ||
|
||
constructor() { | ||
super(ShowEvent.type, { | ||
composed: true, | ||
cancelable: true, | ||
details: null, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,137 +1,100 @@ | ||
import { css } from "lit"; | ||
|
||
// tokens | ||
// --tap-dialog-color-surface-overlay | ||
// --tap-dialog-color-surface-primary | ||
// --tap-dialog-padding | ||
// --tap-dialog-radius | ||
|
||
export default css` | ||
:host { | ||
*, | ||
*::before, | ||
*::after { | ||
box-sizing: border-box; | ||
} | ||
:host *, | ||
:host *::before, | ||
:host *::after { | ||
box-sizing: inherit; | ||
} | ||
[hidden] { | ||
display: none !important; | ||
} | ||
.overlay { | ||
background-color: var( | ||
--tap-dialog-color-surface-overlay, | ||
var(--tap-sys-color-surface-overlay-dark) | ||
); | ||
position: fixed; | ||
left: 0; | ||
right: 0; | ||
top: 0; | ||
bottom: 0; | ||
} | ||
.dialog { | ||
position: fixed; | ||
left: var(--tap-dialog-left, var(--tap-sys-spacing-6)); | ||
right: var(--tap-dialog-right, var(--tap-sys-spacing-6)); | ||
bottom: var(--tap-dialog-bottom, var(--tap-sys-spacing-6)); | ||
background-color: var( | ||
--tap-dialog-color-surface-primary, | ||
var(--tap-sys-color-surface-primary) | ||
); | ||
font-family: var(--tap-dialog-font, var(--tap-sys-font-family)); | ||
border-radius: var(--tap-dialog-radius, var(--tap-sys-radius-6)); | ||
overflow: hidden; | ||
.root.open { | ||
visibility: visible; | ||
opacity: 1; | ||
} | ||
.icon-container { | ||
margin-top: var(--tap-dialog-icon-top-margin, var(--tap-sys-spacing-8)); | ||
display: flex; | ||
justify-content: center; | ||
.root.open .container { | ||
transform: translateY(0); | ||
} | ||
.image-container { | ||
height: 200px; | ||
background-color: var( | ||
--tap-dialog-image-container-background-color, | ||
var(--tap-palette-gray-100) | ||
); | ||
.root.start .body { | ||
text-align: start; | ||
} | ||
::slotted([slot="banner"]) { | ||
width: 100%; | ||
height: 100%; | ||
.root.center { | ||
text-align: center; | ||
} | ||
.content { | ||
padding: var( | ||
--tap-dialog-content-vertical-padding, | ||
var(--tap-sys-spacing-4) | ||
) | ||
var(--tap-dialog-content-horizontal-padding, var(--tap-sys-spacing-6)); | ||
margin: var(--tap-dialog-content-vertical-margin, var(--tap-sys-spacing-6)) | ||
var(--tap-dialog-content-horizontal-margin, 0); | ||
} | ||
.root { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
.center { | ||
text-align: center; | ||
} | ||
visibility: hidden; | ||
opacity: 0; | ||
.right { | ||
text-align: right; | ||
transition: | ||
visibility 240ms ease, | ||
opacity 240ms ease; | ||
} | ||
.left { | ||
text-align: left; | ||
.overlay { | ||
background-color: var(--tap-sys-color-surface-overlay-dark); | ||
position: fixed; | ||
inset: 0; | ||
} | ||
.left { | ||
text-align: left; | ||
.container { | ||
transform: translateY(2rem); | ||
position: fixed; | ||
left: var(--tap-sys-spacing-6); | ||
right: var(--tap-sys-spacing-6); | ||
bottom: var(--tap-sys-spacing-6); | ||
background-color: var(--tap-sys-color-surface-primary); | ||
font-family: var(--tap-sys-font-family); | ||
border-radius: var(--tap-sys-radius-6); | ||
overflow: hidden; | ||
transition: transform 240ms ease; | ||
} | ||
.left { | ||
text-align: left; | ||
.body { | ||
margin-top: var(--tap-sys-spacing-6); | ||
margin-bottom: var(--tap-sys-spacing-6); | ||
padding: var(--tap-sys-spacing-4) var(--tap-sys-spacing-6); | ||
} | ||
.title { | ||
font-size: var( | ||
--tap-dialog-title-size, | ||
var(--tap-sys-typography-headline-sm-size) | ||
); | ||
font-weight: var( | ||
--tap-dialog-title-weight, | ||
var(--tap-sys-typography-headline-sm-weight) | ||
); | ||
line-height: var( | ||
--tap-dialog-title-line-height, | ||
var(--tap-sys-typography-headline-sm-height) | ||
); | ||
color: var(--tap-sys-color-content-primary); | ||
font-size: var(--tap-sys-typography-headline-sm-size); | ||
font-weight: var(--tap-sys-typography-headline-sm-weight); | ||
line-height: var(--tap-sys-typography-headline-sm-height); | ||
} | ||
.description { | ||
margin: var(--tap-dialog-description-margin, 0); | ||
padding-top: var( | ||
--tap-dialog-description-padding-top, | ||
var(--tap-sys-spacing-4) | ||
); | ||
font-size: var( | ||
--tap-dialog-description-font-size, | ||
var(--tap-sys-typography-body-md-size) | ||
); | ||
font-weight: var( | ||
--tap-dialog-description-font-weight, | ||
var(--tap-sys-typography-body-md-weight) | ||
); | ||
line-height: var( | ||
--tap-dialog-description-line-height, | ||
var(--tap-sys-typography-body-md-height) | ||
); | ||
color: var(--tap-dialog-description-color, var(--tap-palette-gray-500)); | ||
color: var(--tap-sys-color-content-tertiary); | ||
font-size: var(--tap-sys-typography-body-md-size); | ||
font-weight: var(--tap-sys-typography-body-md-weight); | ||
line-height: var(--tap-sys-typography-body-md-height); | ||
} | ||
.title + .description { | ||
margin-top: var(--tap-sys-spacing-4); | ||
} | ||
.actions { | ||
padding: var(--tap-dialog-actions-padding, var(--tap-sys-spacing-6)); | ||
padding: var(--tap-sys-spacing-6); | ||
} | ||
.actions ::slotted(*) { | ||
width: 100%; | ||
} | ||
`; |
Oops, something went wrong.