Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Adjust Alert for CMS #31

Merged
merged 8 commits into from
Jun 7, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed

- Adjust `Alert` component for `CMS` ([#31](https://github.com/vtex-sites/gatsby.store/pull/31))
- Added base files (`Getting Started`, `Theming`, `Colors`, `Typography` and `Icons`) to Storybook ([#67](https://github.com/vtex-sites/nextjs.store/pull/67))
- Updated tokens' naming scheme ([#67](https://github.com/vtex-sites/nextjs.store/pull/67))
- `OutOfStock` component ([#72](https://github.com/vtex-sites/nextjs.store/pull/72))
Expand Down
1 change: 1 addition & 0 deletions public/icons.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 10 additions & 3 deletions src/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,16 @@ function Layout({ children }: PropsWithChildren<unknown>) {
return (
<>
<div id="layout">
<Alert>
Get 10% off today:&nbsp;<span>NEW10</span>
</Alert>
<Alert
icon="Bell"
content={
<>
Get 10% off today:&nbsp;<span>NEW10</span>
</>
}
link={{ text: 'Buy now', to: '/office' }}
dismissible
/>

<Navbar />

Expand Down
20 changes: 15 additions & 5 deletions src/components/common/Alert/Alert.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
import { useCallback, useState } from 'react'
import type { PropsWithChildren } from 'react'
import type { ReactNode } from 'react'

import UIAlert from 'src/components/ui/Alert'
import { mark } from 'src/sdk/tests/mark'
import Icon from 'src/components/ui/Icon'

function Alert({ children }: PropsWithChildren<unknown>) {
interface Props {
icon: string
content: ReactNode
link?: {
to: string
text: string
}
dismissible: boolean
}
function Alert({ icon, content, link, dismissible = false }: Props) {
const [displayAlert, setDisplayAlert] = useState(true)

const onAlertClose = useCallback(
Expand All @@ -19,11 +28,12 @@ function Alert({ children }: PropsWithChildren<unknown>) {

return (
<UIAlert
icon={<Icon name="BellRinging" width={24} height={24} />}
dismissible
icon={<Icon name={icon} width={24} height={24} />}
dismissible={dismissible}
onClose={onAlertClose}
link={link}
>
{children}
{content}
lucasfp13 marked this conversation as resolved.
Show resolved Hide resolved
</UIAlert>
)
}
Expand Down