-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
870 additions
and
143 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,118 @@ | ||
|
||
.AlertDialogOverlay { | ||
background-color: rgba(0, 0, 0, 0.5); | ||
position: fixed; | ||
inset: 0; | ||
animation: overlayShow 150ms cubic-bezier(0.16, 1, 0.3, 1); | ||
z-index: 110; | ||
} | ||
|
||
.AlertDialogContent { | ||
background-color: white; | ||
border-radius: 6px; | ||
box-shadow: hsl(206deg 22% 7% / 35%) 0 10px 38px -10px, hsl(206deg 22% 7% / 20%) 0 10px 20px -15px; | ||
position: fixed; | ||
top: 50%; | ||
left: 50%; | ||
transform: translate(-50%, -50%); | ||
width: 90vw; | ||
max-width: 500px; | ||
max-height: 85vh; | ||
padding: 25px; | ||
animation: contentShow 150ms cubic-bezier(0.16, 1, 0.3, 1); | ||
z-index: 110; | ||
} | ||
|
||
.AlertDialogContent:focus { | ||
outline: none; | ||
} | ||
|
||
.AlertDialogTitle { | ||
margin: 0; | ||
color: var(--color-primary); | ||
font-size: 17px; | ||
font-weight: 600; | ||
} | ||
|
||
.AlertDialogDescription { | ||
margin-bottom: 20px; | ||
color: var(--color-primary); | ||
font-size: 15px; | ||
line-height: 1.5; | ||
} | ||
|
||
.AlertDialogButton { | ||
display: inline-flex; | ||
align-items: center; | ||
justify-content: center; | ||
border-radius: 4px; | ||
padding: 0 15px; | ||
font-size: 15px; | ||
line-height: 1; | ||
font-weight: 500; | ||
height: 35px; | ||
} | ||
|
||
.AlertDialogButton.violet { | ||
background-color: white; | ||
color: var(--violet-11); | ||
box-shadow: 0 2px 10px var(--color-primary); | ||
} | ||
|
||
.AlertDialogButton.violet:hover { | ||
background-color: var(--color-accent); | ||
} | ||
|
||
.AlertDialogButton.violet:focus { | ||
box-shadow: 0 0 0 2px black; | ||
} | ||
|
||
.AlertDialogButton.delete { | ||
color: var(--red-11); | ||
border: 2px solid var(--color-alert-red); | ||
transition: 200ms; | ||
} | ||
|
||
.AlertDialogButton.delete:hover { | ||
background-color: var(--color-alert-red); | ||
border: 2px solid var(--color-alert-red); | ||
} | ||
|
||
.AlertDialogButton.delete:focus { | ||
background-color: var(--color-alert-red); | ||
border: 2px solid var(--color-alert-red); | ||
} | ||
|
||
.AlertDialogButton.abort { | ||
color: var(--mauve-11); | ||
border: 2px solid var(--color-medium-grey); | ||
} | ||
|
||
.AlertDialogButton.abort:hover { | ||
border: 2px solid var(--color-abort); | ||
} | ||
|
||
.AlertDialogButton.abort:focus { | ||
border: 2px solid var(--color-abort); | ||
} | ||
|
||
/* @keyframes overlayShow { | ||
from { | ||
opacity: 0; | ||
} | ||
to { | ||
opacity: 1; | ||
} | ||
} */ | ||
|
||
/* @keyframes contentShow { | ||
from { | ||
opacity: 0; | ||
transform: translate(-50%, -48%) scale(0.96); | ||
} | ||
to { | ||
opacity: 1; | ||
transform: translate(-50%, -50%) scale(1); | ||
} | ||
} | ||
*/ |
14 changes: 14 additions & 0 deletions
14
src/renderer/assets/styles/components/alert.modals.css.d.ts
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,14 @@ | ||
declare const styles: { | ||
readonly "AlertDialogOverlay": string; | ||
readonly "overlayShow": string; | ||
readonly "AlertDialogContent": string; | ||
readonly "contentShow": string; | ||
readonly "AlertDialogTitle": string; | ||
readonly "AlertDialogDescription": string; | ||
readonly "AlertDialogButton": string; | ||
readonly "violet": string; | ||
readonly "delete": string; | ||
readonly "abort": string; | ||
}; | ||
export = styles; | ||
|
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
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
136 changes: 136 additions & 0 deletions
136
src/renderer/common/components/dialog/DialogWithRadix.tsx
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,136 @@ | ||
// ==LICENSE-BEGIN== | ||
// Copyright 2017 European Digital Reading Lab. All rights reserved. | ||
// Licensed to the Readium Foundation under one or more contributor license agreements. | ||
// Use of this source code is governed by a BSD-style license | ||
// that can be found in the LICENSE file exposed on Github (readium) in the project repository. | ||
// ==LICENSE-END== | ||
|
||
import * as React from "react"; | ||
import * as Dialog from "@radix-ui/react-dialog"; | ||
import { useTranslator } from "readium-desktop/renderer/common/hooks/useTranslator"; | ||
import * as QuitIcon from "readium-desktop/renderer/assets/icons/baseline-close-24px.svg"; | ||
import SVG from "readium-desktop/renderer/common/components/SVG"; | ||
import { useSelector } from "readium-desktop/renderer/common/hooks/useSelector"; | ||
import * as stylesModals from "readium-desktop/renderer/assets/styles/components/modals.css"; | ||
import * as stylesButtons from "readium-desktop/renderer/assets/styles/components/buttons.css"; | ||
import * as chevronDownIcon from "readium-desktop/renderer/assets/icons/chevron-down.svg"; | ||
import classNames from "classnames"; | ||
import { IRendererCommonRootState } from "readium-desktop/common/redux/states/rendererCommonRootState"; | ||
|
||
export const DialogWithRadix: React.FC<React.PropsWithChildren<{ defaultOpen?: boolean | undefined }>> = (props) => { | ||
const [open, setOpen] = React.useState(false); | ||
|
||
const openFromState = useSelector((state: IRendererCommonRootState) => state.dialog.open); | ||
React.useMemo(() => { | ||
if (!openFromState) { | ||
setOpen(false); | ||
} | ||
}, [openFromState]); | ||
|
||
return ( | ||
<Dialog.Root | ||
defaultOpen={props.defaultOpen} | ||
open={open} | ||
onOpenChange={ | ||
(open) => { | ||
if (open) { | ||
setOpen(true); | ||
} else { | ||
setOpen(false); | ||
} | ||
}} | ||
> | ||
{props.children} | ||
</Dialog.Root> | ||
); | ||
}; | ||
|
||
export const DialogWithRadixTrigger = Dialog.Trigger; | ||
DialogWithRadixTrigger.displayName = Dialog.Trigger.displayName; | ||
|
||
const DialogContext = React.createContext<{ | ||
collapse: { | ||
toggleCollapse: () => void; | ||
isCollapsed: boolean; | ||
}; | ||
}>(undefined); | ||
|
||
export const DialogWithRadixContent: React.FC<React.PropsWithChildren<{}>> = (props) => { | ||
const appOverlayElement = React.useMemo(() => document.getElementById("app-overlay"), []); | ||
const [__] = useTranslator(); | ||
const [isCollapsed, setCollapse] = React.useState(false); | ||
|
||
const toggleCollapse = () => { | ||
setCollapse(!isCollapsed); | ||
}; | ||
|
||
const dialogContextValue = { collapse: { toggleCollapse, isCollapsed } }; | ||
|
||
return ( | ||
<Dialog.Portal container={appOverlayElement}> | ||
<div className={stylesModals.modal_dialog_overlay}></div> | ||
<Dialog.Content className={classNames(stylesModals.modal_dialog, isCollapsed ? stylesModals["modal_dialog-collapsed"] : undefined)} | ||
style={{ | ||
backgroundColor: "white", | ||
zIndex: "10000", | ||
}} | ||
id="modalContainer"> | ||
<DialogContext.Provider value={dialogContextValue}> | ||
{props.children} | ||
</DialogContext.Provider> | ||
</Dialog.Content> | ||
</Dialog.Portal> | ||
); | ||
}; | ||
DialogWithRadixContent.displayName = "DialogWithRadixContent"; | ||
|
||
export const DialogTitle = Dialog.Title; | ||
DialogTitle.displayName = "DialogTitle"; | ||
|
||
|
||
export const DialogHeader: React.FC<React.PropsWithChildren<{}>> = (props) => { | ||
return ( | ||
<div className={stylesModals.modal_dialog_header}> | ||
{props.children} | ||
|
||
</div> | ||
); | ||
}; | ||
|
||
export const DialogCollapseButton: React.FC<{}> = () => { | ||
const {collapse: {toggleCollapse}} = React.useContext(DialogContext); | ||
return ( | ||
<button style={{width: "20px", height: "20px"}} id="chevronButton" onClick={() => toggleCollapse()}> | ||
<SVG ariaHidden={true} svg={chevronDownIcon} /> | ||
</button> | ||
); | ||
}; | ||
|
||
export const DialogCloseButton: React.FC<{}> = () => { | ||
return ( | ||
<Dialog.Close asChild> | ||
<button className={stylesButtons.button_transparency_icon} aria-label="Close"> | ||
<SVG ariaHidden={true} svg={QuitIcon} /> | ||
</button> | ||
</Dialog.Close> | ||
); | ||
}; | ||
|
||
export const DialogContent : React.FC<React.PropsWithChildren<{}>> = (props) => { | ||
const {collapse: {isCollapsed}} = React.useContext(DialogContext); | ||
return ( | ||
<div className={classNames(stylesModals.modal_dialog_body, isCollapsed ? stylesModals["modal_dialog_body-collapsed"]: undefined)}> | ||
{props.children} | ||
</div> | ||
); | ||
}; | ||
|
||
export const DialogFooter: React.FC<React.PropsWithChildren<{}>> = (props) => { | ||
return ( | ||
<div className={stylesModals.modal_dialog_footer}> | ||
{props.children} | ||
</div> | ||
); | ||
}; | ||
|
||
export const DialogClose = Dialog.Close; |
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
Oops, something went wrong.