|
| 1 | +import React from 'react'; |
| 2 | + |
| 3 | +import { ThemeContext, type TSupportedThemes } from '../../theme'; |
| 4 | +import { themes } from '../../lib/constants/colors'; |
| 5 | +import NotifierComponent from './NotifierComponent'; |
| 6 | +import { SubscriptionType } from '../../definitions'; |
| 7 | +import { |
| 8 | + BASE_ROW_HEIGHT, |
| 9 | + BASE_ROW_HEIGHT_CONDENSED, |
| 10 | + ResponsiveLayoutContext |
| 11 | +} from '../../lib/hooks/useResponsiveLayout/useResponsiveLayout'; |
| 12 | + |
| 13 | +const responsiveLayoutProviderValue = { |
| 14 | + fontScale: 1, |
| 15 | + fontScaleLimited: 1, |
| 16 | + isLargeFontScale: false, |
| 17 | + rowHeight: BASE_ROW_HEIGHT, |
| 18 | + rowHeightCondensed: BASE_ROW_HEIGHT_CONDENSED, |
| 19 | + width: 300, |
| 20 | + height: 800 |
| 21 | +}; |
| 22 | + |
| 23 | +const baseNotification = { |
| 24 | + text: 'Hey! How are you doing?', |
| 25 | + payload: { |
| 26 | + _id: '1', |
| 27 | + rid: 'rid-1', |
| 28 | + name: 'general', |
| 29 | + sender: { username: 'rocket.cat' }, |
| 30 | + type: SubscriptionType.CHANNEL |
| 31 | + }, |
| 32 | + title: 'general', |
| 33 | + avatar: 'rocket.cat' |
| 34 | +}; |
| 35 | + |
| 36 | +const Wrapper = ({ children, theme = 'light' }: { children: React.ReactNode; theme?: TSupportedThemes }) => ( |
| 37 | + <ThemeContext.Provider value={{ theme, colors: themes[theme] }}> |
| 38 | + <ResponsiveLayoutContext.Provider value={responsiveLayoutProviderValue}>{children}</ResponsiveLayoutContext.Provider> |
| 39 | + </ThemeContext.Provider> |
| 40 | +); |
| 41 | + |
| 42 | +export default { |
| 43 | + title: 'InAppNotification' |
| 44 | +}; |
| 45 | + |
| 46 | +export const DirectMessage = () => ( |
| 47 | + <Wrapper> |
| 48 | + <NotifierComponent |
| 49 | + notification={{ |
| 50 | + ...baseNotification, |
| 51 | + payload: { |
| 52 | + ...baseNotification.payload, |
| 53 | + type: SubscriptionType.DIRECT, |
| 54 | + sender: { username: 'diego.mello' } |
| 55 | + }, |
| 56 | + title: 'diego.mello', |
| 57 | + avatar: 'diego.mello' |
| 58 | + }} |
| 59 | + /> |
| 60 | + </Wrapper> |
| 61 | +); |
| 62 | +export const ChannelMessage = () => ( |
| 63 | + <Wrapper> |
| 64 | + <NotifierComponent notification={baseNotification} /> |
| 65 | + </Wrapper> |
| 66 | +); |
| 67 | +export const WithDarkTheme = () => ( |
| 68 | + <Wrapper theme='dark'> |
| 69 | + <NotifierComponent notification={baseNotification} /> |
| 70 | + </Wrapper> |
| 71 | +); |
| 72 | +export const WithBlackTheme = () => ( |
| 73 | + <Wrapper theme='black'> |
| 74 | + <NotifierComponent notification={baseNotification} /> |
| 75 | + </Wrapper> |
| 76 | +); |
0 commit comments