-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Alert): changed default Alert actions background (#1240)
- Loading branch information
1 parent
048971c
commit 9693147
Showing
11 changed files
with
135 additions
and
77 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
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,12 @@ | ||
import React from 'react'; | ||
|
||
import {Button} from '../Button'; | ||
|
||
import type {AlertActionProps} from './types'; | ||
import {useAlertContext} from './useAlertContext'; | ||
|
||
export const AlertAction = (props: AlertActionProps) => { | ||
const {view} = useAlertContext(); | ||
|
||
return <Button view={view === 'filled' ? 'normal-contrast' : undefined} {...props} />; | ||
}; |
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,5 @@ | ||
import React from 'react'; | ||
|
||
import type {AlertContextType} from './types'; | ||
|
||
export const AlertContext = React.createContext<AlertContextType | null>(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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import React from 'react'; | ||
|
||
import {AlertContext} from './AlertContext'; | ||
import type {AlertContextProviderProps} from './types'; | ||
|
||
export const AlertContextProvider = ({layout, view, children}: AlertContextProviderProps) => { | ||
return <AlertContext.Provider value={{layout, view}}>{children}</AlertContext.Provider>; | ||
}; |
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 |
---|---|---|
@@ -1,2 +1,8 @@ | ||
export {Alert} from './Alert'; | ||
export type {AlertProps} from './types'; | ||
export type { | ||
AlertProps, | ||
AlertTitleProps, | ||
AlertActionProps, | ||
AlertActionsProps, | ||
AlertIconProps, | ||
} from './types'; |
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,11 @@ | ||
import React from 'react'; | ||
|
||
import {AlertContext} from './AlertContext'; | ||
|
||
export const useAlertContext = () => { | ||
const context = React.useContext(AlertContext); | ||
|
||
if (!context) throw new Error('Alert: `useAlertContext` hook is used out of "AlertContext"'); | ||
|
||
return context; | ||
}; |