-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #63 from wethegit/feature/comp/modal
feature(comp): adds `<Modal>` component
- Loading branch information
Showing
22 changed files
with
377 additions
and
31 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,6 @@ | ||
--- | ||
"@wethegit/components-cli": patch | ||
"@wethegit/components": patch | ||
--- | ||
|
||
Adds `<Modal />` component |
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,6 +1,11 @@ | ||
{ | ||
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json", | ||
"changelog": "@changesets/cli/changelog", | ||
"changelog": [ | ||
"@changesets/changelog-github", | ||
{ | ||
"repo": "wethegit/component-library" | ||
} | ||
], | ||
"commit": false, | ||
"fixed": [], | ||
"linked": [], | ||
|
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
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
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
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
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,2 @@ | ||
export { Modal } from "./modal" | ||
export type { ModalProps } from "./modal" |
38 changes: 38 additions & 0 deletions
38
packages/wethegit-components/src/components/modal/modal.module.scss
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,38 @@ | ||
.modal { | ||
opacity: var(--scale, 0); | ||
transition: opacity var(--duration) ease-in-out; | ||
} | ||
|
||
.modalOpen { | ||
--ease: cubic-bezier(0.77, 0, 0.1, 1.39); | ||
--scale: 1; | ||
} | ||
|
||
.modalBackdrop { | ||
background-color: rgb(0 0 0 / 70%); | ||
} | ||
|
||
.modalCloseButton { | ||
background-color: yellow; | ||
border: none; | ||
border-radius: 0.25rem; | ||
color: black; | ||
cursor: pointer; | ||
font-size: 1rem; | ||
padding: 0.5em 1em; | ||
position: absolute; | ||
right: 1em; | ||
top: -0.5em; | ||
} | ||
|
||
.modalContent { | ||
background-color: white; | ||
border-radius: 1rem; | ||
box-shadow: 0 0 5px 0 rgb(0 0 0 / 20%); | ||
font-family: sans-serif; | ||
max-width: 70%; | ||
-webkit-overflow-scrolling: touch; | ||
padding: 2rem; | ||
transform: scale(var(--scale, 0)); | ||
transition: transform var(--duration) var(--ease, cubic-bezier(0.75, -0.46, 0.4, 1)); | ||
} |
80 changes: 80 additions & 0 deletions
80
packages/wethegit-components/src/components/modal/modal.stories.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,80 @@ | ||
import type { Meta, StoryObj } from "@storybook/react" | ||
import { UserPreferencesProvider } from "@wethegit/react-hooks" | ||
import { useModal } from "@wethegit/react-modal" | ||
import { useRef } from "react" | ||
|
||
import { Modal } from "./modal" | ||
|
||
const meta = { | ||
title: "components/modal", | ||
component: Modal, | ||
args: { | ||
isOpen: true, | ||
}, | ||
decorators: [ | ||
(Story) => ( | ||
<div style={{ height: 500 }}> | ||
<UserPreferencesProvider> | ||
<Story /> | ||
</UserPreferencesProvider> | ||
</div> | ||
), | ||
], | ||
} satisfies Meta<typeof Modal> | ||
|
||
export default meta | ||
|
||
type Story = StoryObj<typeof Modal> | ||
|
||
export const Default: Story = { | ||
render: (args) => { | ||
return ( | ||
<Modal {...args} appendToBody={false}> | ||
<p style={{ color: "black", margin: 0 }}> | ||
<strong>Close</strong> button doesn't work becayse inside the story we use the{" "} | ||
<code>isOpen</code> control. | ||
</p> | ||
</Modal> | ||
) | ||
}, | ||
} | ||
|
||
export const WithButtonTrigger: Story = { | ||
render: () => { | ||
const triggerRef = useRef<HTMLButtonElement>(null) | ||
const { isOpen, toggle } = useModal({ | ||
triggerRef, | ||
}) | ||
|
||
return ( | ||
<div | ||
style={{ | ||
display: "flex", | ||
justifyContent: "center", | ||
height: "100%", | ||
alignItems: "center", | ||
}} | ||
> | ||
<button | ||
ref={triggerRef} | ||
onClick={toggle} | ||
style={{ | ||
backgroundColor: "cyan", | ||
padding: "20px", | ||
color: "black", | ||
fontFamily: "sans-serif", | ||
borderRadius: "5px", | ||
}} | ||
> | ||
{isOpen ? "Close" : "Open"} Modal | ||
</button> | ||
<Modal isOpen={isOpen} toggle={toggle}> | ||
<p style={{ color: "black", margin: 0 }}> | ||
<strong>Close</strong> button doesn't work becayse inside the story we use the{" "} | ||
<code>isOpen</code> control. | ||
</p> | ||
</Modal> | ||
</div> | ||
) | ||
}, | ||
} |
Oops, something went wrong.