@bloom-housing/ui-components 2.0.0-pre-tailwind
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.jest/setup-tests.js +24 -0
- package/CHANGELOG.md +20 -0
- package/README.md +195 -0
- package/index.ts +148 -0
- package/jest.config.js +41 -0
- package/package.json +98 -0
- package/public/images/alameda-logo-white.svg +1 -0
- package/public/images/arrow-down.png +0 -0
- package/public/images/arrow-down.svg +1 -0
- package/public/images/check.png +0 -0
- package/public/images/check.svg +11 -0
- package/public/images/eho-logo-white.svg +1 -0
- package/public/images/eho-logo.svg +1 -0
- package/public/images/logo_glyph.svg +11 -0
- package/src/actions/Button.scss +157 -0
- package/src/actions/Button.tsx +80 -0
- package/src/actions/ExpandableContent.tsx +29 -0
- package/src/actions/ExpandableText.scss +18 -0
- package/src/actions/ExpandableText.tsx +52 -0
- package/src/actions/LinkButton.tsx +30 -0
- package/src/actions/LocalizedLink.tsx +11 -0
- package/src/authentication/AuthContext.ts +327 -0
- package/src/authentication/RequireLogin.tsx +62 -0
- package/src/authentication/index.ts +5 -0
- package/src/authentication/timeout.tsx +127 -0
- package/src/authentication/token.ts +17 -0
- package/src/authentication/useRequireLoggedInUser.ts +19 -0
- package/src/blocks/ActionBlock.scss +108 -0
- package/src/blocks/ActionBlock.tsx +51 -0
- package/src/blocks/AppStatusItem.scss +140 -0
- package/src/blocks/AppStatusItem.tsx +75 -0
- package/src/blocks/DashBlock.tsx +42 -0
- package/src/blocks/DashBlocks.scss +56 -0
- package/src/blocks/DashBlocks.tsx +7 -0
- package/src/blocks/FormCard.scss +201 -0
- package/src/blocks/FormCard.tsx +29 -0
- package/src/blocks/HousingCounselor.tsx +51 -0
- package/src/blocks/ImageCard.scss +91 -0
- package/src/blocks/ImageCard.tsx +77 -0
- package/src/blocks/InfoCard.scss +42 -0
- package/src/blocks/InfoCard.tsx +44 -0
- package/src/blocks/StatusBar.scss +30 -0
- package/src/blocks/StatusBar.tsx +31 -0
- package/src/blocks/ViewItem.scss +59 -0
- package/src/blocks/ViewItem.tsx +32 -0
- package/src/config/ConfigContext.tsx +36 -0
- package/src/config/NavigationContext.tsx +54 -0
- package/src/config/index.ts +2 -0
- package/src/footers/ExygyFooter.tsx +12 -0
- package/src/footers/SiteFooter.scss +28 -0
- package/src/footers/SiteFooter.tsx +10 -0
- package/src/forms/CloudinaryUpload.ts +50 -0
- package/src/forms/DOBField.tsx +132 -0
- package/src/forms/DateField.tsx +120 -0
- package/src/forms/Dropzone.scss +17 -0
- package/src/forms/Dropzone.tsx +67 -0
- package/src/forms/Field.tsx +115 -0
- package/src/forms/FieldGroup.tsx +82 -0
- package/src/forms/Form.tsx +22 -0
- package/src/forms/HouseholdMemberForm.tsx +41 -0
- package/src/forms/HouseholdSizeField.tsx +74 -0
- package/src/forms/PhoneField.tsx +69 -0
- package/src/forms/PhoneMask.tsx +24 -0
- package/src/forms/Select.tsx +80 -0
- package/src/forms/Textarea.scss +40 -0
- package/src/forms/Textarea.tsx +64 -0
- package/src/forms/TimeField.tsx +176 -0
- package/src/global/AppearanceTypes.ts +46 -0
- package/src/global/ApplicationStatusType.ts +6 -0
- package/src/global/accordion.scss +4 -0
- package/src/global/blocks.scss +137 -0
- package/src/global/custom_counter.scss +50 -0
- package/src/global/forms.scss +362 -0
- package/src/global/headers.scss +89 -0
- package/src/global/homepage.scss +8 -0
- package/src/global/index.scss +72 -0
- package/src/global/lists.scss +21 -0
- package/src/global/markdown.scss +33 -0
- package/src/global/mixins.scss +175 -0
- package/src/global/navbar.scss +280 -0
- package/src/global/print.scss +59 -0
- package/src/global/tables.scss +197 -0
- package/src/global/text.scss +141 -0
- package/src/global/vendor/AgPagination.tsx +133 -0
- package/src/global/vendor/_setup_bulma.scss +31 -0
- package/src/global/vendor/ag_grid.scss +140 -0
- package/src/headers/Hero.scss +56 -0
- package/src/headers/Hero.tsx +76 -0
- package/src/headers/PageHeader.scss +31 -0
- package/src/headers/PageHeader.tsx +39 -0
- package/src/headers/SiteHeader.tsx +136 -0
- package/src/helpers/address.tsx +46 -0
- package/src/helpers/blankApplication.ts +108 -0
- package/src/helpers/capitalize.tsx +7 -0
- package/src/helpers/dateToString.ts +11 -0
- package/src/helpers/debounce.ts +12 -0
- package/src/helpers/formOptions.tsx +229 -0
- package/src/helpers/formatYesNoLabel.ts +9 -0
- package/src/helpers/getTranslationWithArguments.ts +14 -0
- package/src/helpers/links.ts +7 -0
- package/src/helpers/localeRoute.tsx +13 -0
- package/src/helpers/mergeDeep.ts +12 -0
- package/src/helpers/nextjs.ts +7 -0
- package/src/helpers/numberOrdinal.ts +17 -0
- package/src/helpers/occupancyFormatting.tsx +46 -0
- package/src/helpers/pdfs.ts +19 -0
- package/src/helpers/photos.ts +19 -0
- package/src/helpers/preferences.tsx +426 -0
- package/src/helpers/resolveObject.ts +5 -0
- package/src/helpers/state.tsx +7 -0
- package/src/helpers/tableSummaries.tsx +80 -0
- package/src/helpers/translator.tsx +37 -0
- package/src/helpers/useKeyPress.ts +17 -0
- package/src/helpers/useMutate.ts +40 -0
- package/src/helpers/useOutsideClick.ts +25 -0
- package/src/helpers/validators.ts +3 -0
- package/src/icons/HeaderBadge.scss +29 -0
- package/src/icons/HeaderBadge.tsx +38 -0
- package/src/icons/Icon.scss +76 -0
- package/src/icons/Icon.tsx +145 -0
- package/src/icons/Icons.tsx +556 -0
- package/src/lists/PreferencesList.scss +72 -0
- package/src/lists/PreferencesList.tsx +60 -0
- package/src/locales/es.json +745 -0
- package/src/locales/general.json +1307 -0
- package/src/locales/general_OLD.json +868 -0
- package/src/locales/vi.json +745 -0
- package/src/locales/zh.json +745 -0
- package/src/navigation/Breadcrumbs.scss +25 -0
- package/src/navigation/Breadcrumbs.tsx +27 -0
- package/src/navigation/FooterNav.scss +47 -0
- package/src/navigation/FooterNav.tsx +19 -0
- package/src/navigation/LanguageNav.scss +32 -0
- package/src/navigation/LanguageNav.tsx +53 -0
- package/src/navigation/ProgressNav.scss +102 -0
- package/src/navigation/ProgressNav.tsx +50 -0
- package/src/navigation/TabNav.scss +38 -0
- package/src/navigation/TabNav.tsx +69 -0
- package/src/navigation/Tabs.scss +65 -0
- package/src/navigation/Tabs.tsx +93 -0
- package/src/navigation/UserNav.tsx +37 -0
- package/src/notifications/AlertBox.scss +78 -0
- package/src/notifications/AlertBox.tsx +79 -0
- package/src/notifications/AlertNotice.scss +58 -0
- package/src/notifications/AlertNotice.tsx +37 -0
- package/src/notifications/ApplicationStatus.scss +10 -0
- package/src/notifications/ApplicationStatus.tsx +64 -0
- package/src/notifications/ErrorMessage.tsx +15 -0
- package/src/notifications/SiteAlert.tsx +54 -0
- package/src/notifications/StatusAside.scss +11 -0
- package/src/notifications/StatusAside.tsx +25 -0
- package/src/notifications/StatusMessage.scss +25 -0
- package/src/notifications/StatusMessage.tsx +59 -0
- package/src/notifications/alertTypes.ts +7 -0
- package/src/notifications/index.ts +4 -0
- package/src/overlays/Drawer.scss +105 -0
- package/src/overlays/Drawer.tsx +51 -0
- package/src/overlays/LoadingOverlay.scss +25 -0
- package/src/overlays/LoadingOverlay.tsx +29 -0
- package/src/overlays/Modal.scss +55 -0
- package/src/overlays/Modal.tsx +61 -0
- package/src/overlays/Overlay.scss +50 -0
- package/src/overlays/Overlay.tsx +100 -0
- package/src/page_components/listing/AdditionalFees.tsx +56 -0
- package/src/page_components/listing/ListingCard.scss +47 -0
- package/src/page_components/listing/ListingCard.tsx +34 -0
- package/src/page_components/listing/ListingDetailHeader.tsx +25 -0
- package/src/page_components/listing/ListingDetails.tsx +29 -0
- package/src/page_components/listing/ListingMap.scss +36 -0
- package/src/page_components/listing/ListingMap.tsx +138 -0
- package/src/page_components/listing/ListingsGroup.scss +65 -0
- package/src/page_components/listing/ListingsGroup.tsx +49 -0
- package/src/page_components/listing/UnitTables.tsx +111 -0
- package/src/page_components/listing/listing_sidebar/ApplicationSection.tsx +49 -0
- package/src/page_components/listing/listing_sidebar/Apply.tsx +225 -0
- package/src/page_components/listing/listing_sidebar/LeasingAgent.tsx +77 -0
- package/src/page_components/listing/listing_sidebar/ListingUpdated.tsx +20 -0
- package/src/page_components/listing/listing_sidebar/ReferralApplication.tsx +28 -0
- package/src/page_components/listing/listing_sidebar/SidebarAddress.tsx +56 -0
- package/src/page_components/listing/listing_sidebar/Waitlist.tsx +94 -0
- package/src/page_components/listing/listing_sidebar/WhatToExpect.tsx +22 -0
- package/src/page_components/listing/listing_sidebar/events/DownloadLotteryResults.tsx +34 -0
- package/src/page_components/listing/listing_sidebar/events/EventDateSection.tsx +24 -0
- package/src/page_components/listing/listing_sidebar/events/LotteryResultsEvent.tsx +26 -0
- package/src/page_components/listing/listing_sidebar/events/OpenHouseEvent.tsx +27 -0
- package/src/page_components/listing/listing_sidebar/events/PublicLotteryEvent.tsx +22 -0
- package/src/prototypes/AppCard.scss +64 -0
- package/src/prototypes/Back.scss +19 -0
- package/src/prototypes/ButtonGroup.scss +6 -0
- package/src/prototypes/ButtonPager.scss +22 -0
- package/src/prototypes/FieldSection.scss +35 -0
- package/src/prototypes/FieldSection.tsx +31 -0
- package/src/prototypes/GridItem.tsx +15 -0
- package/src/prototypes/SideNav.scss +32 -0
- package/src/prototypes/SideNav.tsx +14 -0
- package/src/prototypes/SummaryCard.scss +34 -0
- package/src/sections/ContentSection.scss +15 -0
- package/src/sections/ContentSection.tsx +25 -0
- package/src/sections/FooterSection.scss +6 -0
- package/src/sections/FooterSection.tsx +16 -0
- package/src/sections/GridSection.scss +72 -0
- package/src/sections/GridSection.tsx +82 -0
- package/src/sections/InfoCardGrid.scss +45 -0
- package/src/sections/InfoCardGrid.tsx +20 -0
- package/src/sections/ListSection.scss +7 -0
- package/src/sections/ListSection.tsx +23 -0
- package/src/sections/MarkdownSection.scss +13 -0
- package/src/sections/MarkdownSection.tsx +21 -0
- package/src/sections/ResponsiveContentList.tsx +67 -0
- package/src/sections/ResponsiveWrappers.tsx +23 -0
- package/src/tables/GroupedTable.tsx +86 -0
- package/src/tables/MinimalTable.tsx +32 -0
- package/src/tables/ResponsiveTable.tsx +24 -0
- package/src/tables/StandardTable.tsx +229 -0
- package/src/text/Description.scss +52 -0
- package/src/text/Description.tsx +24 -0
- package/src/text/Message.scss +16 -0
- package/src/text/Message.tsx +16 -0
- package/src/text/Tag.scss +94 -0
- package/src/text/Tag.tsx +22 -0
- package/tailwind.config.js +128 -0
- package/tailwind.tosass.js +29 -0
- package/tsconfig.json +31 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
.tabs {
|
|
2
|
+
ul {
|
|
3
|
+
@apply block;
|
|
4
|
+
@screen md {
|
|
5
|
+
@apply flex;
|
|
6
|
+
}
|
|
7
|
+
@apply items-center;
|
|
8
|
+
@apply font-alt-sans;
|
|
9
|
+
@apply text-sm;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.tabs__tab {
|
|
14
|
+
@apply bg-white;
|
|
15
|
+
@apply text-gray-800;
|
|
16
|
+
@apply px-6;
|
|
17
|
+
@apply pt-3;
|
|
18
|
+
padding-bottom: 0.65rem;
|
|
19
|
+
@apply border;
|
|
20
|
+
@apply border-gray-450;
|
|
21
|
+
@apply border-b-2;
|
|
22
|
+
@screen md {
|
|
23
|
+
@apply border-l-0;
|
|
24
|
+
}
|
|
25
|
+
@apply block;
|
|
26
|
+
border-bottom-color: transparent;
|
|
27
|
+
cursor: pointer;
|
|
28
|
+
|
|
29
|
+
&:first-of-type {
|
|
30
|
+
@apply border-l;
|
|
31
|
+
@apply rounded-tl-lg;
|
|
32
|
+
@apply rounded-tr-lg;
|
|
33
|
+
@screen md {
|
|
34
|
+
@apply rounded-tr-none;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
&:last-of-type {
|
|
38
|
+
@screen md {
|
|
39
|
+
@apply rounded-tr-lg;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
&:hover {
|
|
43
|
+
border-bottom-color: map-get($tailwind-gray, 400);
|
|
44
|
+
}
|
|
45
|
+
&[aria-selected="true"] {
|
|
46
|
+
@apply text-black;
|
|
47
|
+
border-bottom-color: $tailwind-primary;
|
|
48
|
+
}
|
|
49
|
+
&[aria-disabled="true"] {
|
|
50
|
+
@apply text-gray-600;
|
|
51
|
+
@apply cursor-not-allowed;
|
|
52
|
+
border-bottom-color: transparent;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.tabs__panel {
|
|
57
|
+
@apply p-8;
|
|
58
|
+
@apply bg-white;
|
|
59
|
+
@apply border;
|
|
60
|
+
@apply border-gray-450;
|
|
61
|
+
|
|
62
|
+
&:not(.is-active) {
|
|
63
|
+
display: none;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import React, { FunctionComponent } from "react"
|
|
2
|
+
import "./Tabs.scss"
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
Tab as ReactTab,
|
|
6
|
+
Tabs as ReactTabs,
|
|
7
|
+
TabList as ReactTabList,
|
|
8
|
+
TabPanel as ReactTabPanel,
|
|
9
|
+
} from "react-tabs"
|
|
10
|
+
|
|
11
|
+
export interface TabsProps {
|
|
12
|
+
children: React.ReactNode
|
|
13
|
+
className?: string
|
|
14
|
+
defaultFocus?: boolean
|
|
15
|
+
defaultIndex?: number
|
|
16
|
+
disabledTabClassName?: string
|
|
17
|
+
domRef?: (node?: HTMLElement) => void
|
|
18
|
+
forceRenderTabPanel?: boolean
|
|
19
|
+
onSelect?: (index: number, last: number, event: Event) => boolean | void
|
|
20
|
+
selectedIndex?: number
|
|
21
|
+
selectedTabClassName?: string
|
|
22
|
+
selectedTabPanelClassName?: string
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const Tabs: FunctionComponent<TabsProps> = ({ children, ...props }: TabsProps) => {
|
|
26
|
+
const className = ["tabs"]
|
|
27
|
+
if (props.className) className.push(props.className)
|
|
28
|
+
return (
|
|
29
|
+
<ReactTabs {...props} className={className.join(" ")}>
|
|
30
|
+
{children}
|
|
31
|
+
</ReactTabs>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface TabProps {
|
|
36
|
+
children: React.ReactNode
|
|
37
|
+
className?: string
|
|
38
|
+
disabled?: boolean
|
|
39
|
+
disabledClassName?: string
|
|
40
|
+
selectedClassName?: string
|
|
41
|
+
tabIndex?: string
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const Tab: FunctionComponent<TabProps> = ({ children, ...props }: TabProps) => {
|
|
45
|
+
const className = ["tabs__tab"]
|
|
46
|
+
if (props.className) className.push(props.className)
|
|
47
|
+
return (
|
|
48
|
+
<ReactTab selectedClassName="is-active" {...props} className={className}>
|
|
49
|
+
{children}
|
|
50
|
+
</ReactTab>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
55
|
+
// @ts-ignore
|
|
56
|
+
Tab.tabsRole = "Tab"
|
|
57
|
+
|
|
58
|
+
export interface TabListProps {
|
|
59
|
+
children: React.ReactNode
|
|
60
|
+
className?: string | string[] | { [name: string]: boolean }
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export const TabList: FunctionComponent<TabListProps> = ({ children, ...props }: TabListProps) => {
|
|
64
|
+
return <ReactTabList {...props}>{children}</ReactTabList>
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
68
|
+
// @ts-ignore
|
|
69
|
+
TabList.tabsRole = "TabList"
|
|
70
|
+
|
|
71
|
+
export interface TabPanelProps {
|
|
72
|
+
children: React.ReactNode
|
|
73
|
+
className?: string
|
|
74
|
+
forceRender?: boolean
|
|
75
|
+
selectedClassName?: string
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export const TabPanel: FunctionComponent<TabPanelProps> = ({
|
|
79
|
+
children,
|
|
80
|
+
...props
|
|
81
|
+
}: TabPanelProps) => {
|
|
82
|
+
const className = ["tabs__panel"]
|
|
83
|
+
if (props.className) className.push(props.className)
|
|
84
|
+
return (
|
|
85
|
+
<ReactTabPanel selectedClassName="is-active" {...props} className={className}>
|
|
86
|
+
{children}
|
|
87
|
+
</ReactTabPanel>
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
92
|
+
// @ts-ignore
|
|
93
|
+
TabPanel.tabsRole = "TabPanel"
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { LocalizedLink } from "../actions/LocalizedLink"
|
|
3
|
+
import { t } from "../helpers/translator"
|
|
4
|
+
import { NavbarDropdown } from "../headers/SiteHeader"
|
|
5
|
+
|
|
6
|
+
export interface UserNavProps {
|
|
7
|
+
signedIn: boolean
|
|
8
|
+
children: React.ReactNode
|
|
9
|
+
signOut: () => void
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const UserNav = (props: UserNavProps) => {
|
|
13
|
+
const { signedIn, children, signOut } = props
|
|
14
|
+
|
|
15
|
+
if (signedIn) {
|
|
16
|
+
return (
|
|
17
|
+
<>
|
|
18
|
+
<NavbarDropdown menuTitle={t("nav.myAccount")}>
|
|
19
|
+
{children}
|
|
20
|
+
<a href="#" className="navbar-item" onClick={signOut}>
|
|
21
|
+
{t("nav.signOut")}
|
|
22
|
+
</a>
|
|
23
|
+
</NavbarDropdown>
|
|
24
|
+
</>
|
|
25
|
+
)
|
|
26
|
+
} else {
|
|
27
|
+
return (
|
|
28
|
+
<>
|
|
29
|
+
<LocalizedLink className="navbar-item" href="/sign-in">
|
|
30
|
+
{t("nav.signIn")}
|
|
31
|
+
</LocalizedLink>
|
|
32
|
+
</>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export { UserNav as default, UserNav }
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
.alert-box {
|
|
2
|
+
@apply relative;
|
|
3
|
+
@apply py-4;
|
|
4
|
+
@apply pr-10;
|
|
5
|
+
@apply leading-snug;
|
|
6
|
+
@apply flex;
|
|
7
|
+
@apply items-center;
|
|
8
|
+
|
|
9
|
+
.alert-box_inner {
|
|
10
|
+
@apply m-auto;
|
|
11
|
+
@apply max-w-5xl;
|
|
12
|
+
@apply px-4;
|
|
13
|
+
@apply flex-1;
|
|
14
|
+
@apply flex;
|
|
15
|
+
@apply items-center;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&.fullWidth {
|
|
19
|
+
@apply px-4;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
&.narrow {
|
|
23
|
+
@apply py-2;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Inverts color scheme of alert
|
|
27
|
+
&.invert {
|
|
28
|
+
@apply text-white;
|
|
29
|
+
|
|
30
|
+
.close {
|
|
31
|
+
@apply text-white;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&.alert {
|
|
36
|
+
@apply bg-alert-light;
|
|
37
|
+
|
|
38
|
+
&.invert {
|
|
39
|
+
@apply bg-alert;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&.primary {
|
|
44
|
+
@apply bg-primary-light;
|
|
45
|
+
|
|
46
|
+
&.invert {
|
|
47
|
+
@apply bg-primary;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
&.success {
|
|
52
|
+
@apply bg-success-light;
|
|
53
|
+
|
|
54
|
+
&.invert {
|
|
55
|
+
@apply bg-success;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
&.warn {
|
|
60
|
+
@apply bg-warn-light;
|
|
61
|
+
|
|
62
|
+
&.invert {
|
|
63
|
+
@apply bg-warn;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.alert-box__body {
|
|
69
|
+
@apply ml-2;
|
|
70
|
+
@apply font-semibold;
|
|
71
|
+
@apply text-tiny;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.alert-box__close {
|
|
75
|
+
@apply absolute;
|
|
76
|
+
@apply text-3xl;
|
|
77
|
+
right: 1rem;
|
|
78
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import React, { useState } from "react"
|
|
2
|
+
import type { ReactNode } from "react"
|
|
3
|
+
import { Icon, IconTypes, IconFillColors } from "../icons/Icon"
|
|
4
|
+
import type { AlertTypes } from "./alertTypes"
|
|
5
|
+
import { colorClasses } from "./alertTypes"
|
|
6
|
+
import "./AlertBox.scss"
|
|
7
|
+
|
|
8
|
+
export interface AlertBoxProps {
|
|
9
|
+
type?: AlertTypes
|
|
10
|
+
closeable?: boolean
|
|
11
|
+
onClose?: () => void
|
|
12
|
+
children: ReactNode
|
|
13
|
+
inverted?: boolean
|
|
14
|
+
className?: string
|
|
15
|
+
boundToLayoutWidth?: boolean
|
|
16
|
+
narrow?: boolean
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const icons: { [k in AlertTypes]: IconTypes } = {
|
|
20
|
+
alert: "warning",
|
|
21
|
+
notice: "info",
|
|
22
|
+
success: "check",
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const AlertBox = (props: AlertBoxProps) => {
|
|
26
|
+
const [showing, setShowing] = useState(true)
|
|
27
|
+
let { onClose, closeable } = props
|
|
28
|
+
|
|
29
|
+
const classNames = [
|
|
30
|
+
"alert-box",
|
|
31
|
+
colorClasses[props.type || "alert"],
|
|
32
|
+
...(props.inverted ? ["invert"] : []),
|
|
33
|
+
...(props.className ? [props.className] : []),
|
|
34
|
+
...(props.boundToLayoutWidth ? [] : ["fullWidth"]),
|
|
35
|
+
...(props.narrow ? ["narrow"] : []),
|
|
36
|
+
].join(" ")
|
|
37
|
+
|
|
38
|
+
if (onClose) closeable = true
|
|
39
|
+
|
|
40
|
+
if (!onClose && closeable) {
|
|
41
|
+
onClose = () => {
|
|
42
|
+
setShowing(false)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
let innerSection = (
|
|
47
|
+
<>
|
|
48
|
+
<span className="alert-box__icon">
|
|
49
|
+
<Icon
|
|
50
|
+
size="medium"
|
|
51
|
+
symbol={icons[props.type || "alert"]}
|
|
52
|
+
fill={props.inverted ? IconFillColors.white : undefined}
|
|
53
|
+
/>
|
|
54
|
+
</span>
|
|
55
|
+
<span className="alert-box__body">
|
|
56
|
+
{typeof props.children === "string" ? <p>{props.children}</p> : props.children}
|
|
57
|
+
</span>
|
|
58
|
+
{closeable && (
|
|
59
|
+
<button
|
|
60
|
+
className={`alert-box__close ${props.inverted ? "text-white" : ""}`}
|
|
61
|
+
onClick={onClose}
|
|
62
|
+
>
|
|
63
|
+
×
|
|
64
|
+
</button>
|
|
65
|
+
)}
|
|
66
|
+
</>
|
|
67
|
+
)
|
|
68
|
+
if (props.boundToLayoutWidth) {
|
|
69
|
+
innerSection = <div className="alert-box_inner">{innerSection}</div>
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return showing ? (
|
|
73
|
+
<div className={classNames} role="alert">
|
|
74
|
+
{innerSection}
|
|
75
|
+
</div>
|
|
76
|
+
) : null
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export { AlertBox as default, AlertBox }
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// secondary alert messaging
|
|
2
|
+
.alert-notice {
|
|
3
|
+
@apply text-sm;
|
|
4
|
+
@apply py-4;
|
|
5
|
+
@apply px-8;
|
|
6
|
+
@apply bg-gray-200;
|
|
7
|
+
@apply border-2;
|
|
8
|
+
@apply border-solid;
|
|
9
|
+
@apply border-primary;
|
|
10
|
+
|
|
11
|
+
&.alert {
|
|
12
|
+
@apply border-alert-light;
|
|
13
|
+
|
|
14
|
+
&.invert {
|
|
15
|
+
@apply border-alert;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&.primary {
|
|
20
|
+
@apply border-primary-light;
|
|
21
|
+
|
|
22
|
+
&.invert {
|
|
23
|
+
@apply border-primary;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&.success {
|
|
28
|
+
@apply border-success-light;
|
|
29
|
+
|
|
30
|
+
&.invert {
|
|
31
|
+
@apply border-success;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
p {
|
|
36
|
+
@apply text-sm;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.alert-notice__title {
|
|
41
|
+
@apply text-sm;
|
|
42
|
+
@apply mb-3;
|
|
43
|
+
@apply font-semibold;
|
|
44
|
+
|
|
45
|
+
&.alert {
|
|
46
|
+
@apply text-alert;
|
|
47
|
+
}
|
|
48
|
+
&.primary {
|
|
49
|
+
@apply text-primary;
|
|
50
|
+
}
|
|
51
|
+
&.success {
|
|
52
|
+
@apply text-success;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.alert-notice__body {
|
|
57
|
+
@apply text-sm;
|
|
58
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import type { ReactNode } from "react"
|
|
3
|
+
import type { AlertTypes } from "./alertTypes"
|
|
4
|
+
import { colorClasses } from "./alertTypes"
|
|
5
|
+
import "./AlertNotice.scss"
|
|
6
|
+
|
|
7
|
+
export interface AlertNoticeProps {
|
|
8
|
+
type?: AlertTypes
|
|
9
|
+
inverted?: boolean
|
|
10
|
+
title: ReactNode
|
|
11
|
+
children: ReactNode
|
|
12
|
+
className?: string
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const AlertNotice = (props: AlertNoticeProps) => {
|
|
16
|
+
const colorClass = colorClasses[props.type || "alert"]
|
|
17
|
+
const classNames = [
|
|
18
|
+
"alert-notice",
|
|
19
|
+
colorClass,
|
|
20
|
+
...(props.className ? [props.className] : []),
|
|
21
|
+
...(props.inverted ? ["invert"] : []),
|
|
22
|
+
].join(" ")
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<div className={classNames}>
|
|
26
|
+
<div className={`alert-notice__title ${colorClass}`}>
|
|
27
|
+
{typeof props.title === "string" ? <p>{props.title}</p> : props.title}
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
<div className="alert-notice__body">
|
|
31
|
+
{typeof props.children === "string" ? <p>{props.children}</p> : props.children}
|
|
32
|
+
</div>
|
|
33
|
+
</div>
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export { AlertNotice as default, AlertNotice }
|