@thecb/components 2.2.0
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/.eslintrc.json +29 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +18 -0
- package/.github/stale.yml +17 -0
- package/.prettierignore +3 -0
- package/.tool-versions +1 -0
- package/README.md +149 -0
- package/dist/cb-components.cjs.js +77 -0
- package/package.json +96 -0
- package/rollup.config.js +35 -0
- package/src/components/atoms/alert/Alert.js +67 -0
- package/src/components/atoms/alert/Alert.theme.js +71 -0
- package/src/components/atoms/alert/index.js +3 -0
- package/src/components/atoms/amount-callout/AmountCallout.js +27 -0
- package/src/components/atoms/amount-callout/AmountCallout.theme.js +19 -0
- package/src/components/atoms/amount-callout/index.js +3 -0
- package/src/components/atoms/breadcrumb/Breadcrumb.js +50 -0
- package/src/components/atoms/breadcrumb/Breadcrumb.theme.js +25 -0
- package/src/components/atoms/breadcrumb/index.js +3 -0
- package/src/components/atoms/button-with-action/ButtonWithAction.js +128 -0
- package/src/components/atoms/button-with-action/ButtonWithAction.stories.js +125 -0
- package/src/components/atoms/button-with-action/ButtonWithAction.theme.js +360 -0
- package/src/components/atoms/button-with-action/index.js +3 -0
- package/src/components/atoms/button-with-link/ButtonWithLink.js +40 -0
- package/src/components/atoms/button-with-link/index.js +3 -0
- package/src/components/atoms/checkbox/Checkbox.js +143 -0
- package/src/components/atoms/checkbox/Checkbox.theme.js +54 -0
- package/src/components/atoms/checkbox/index.js +3 -0
- package/src/components/atoms/checkbox-list/CheckboxList.js +129 -0
- package/src/components/atoms/checkbox-list/CheckboxList.theme.js +42 -0
- package/src/components/atoms/checkbox-list/index.js +3 -0
- package/src/components/atoms/country-dropdown/CountryDropdown.js +24 -0
- package/src/components/atoms/country-dropdown/index.js +1 -0
- package/src/components/atoms/country-dropdown/options.js +249 -0
- package/src/components/atoms/display-box/DisplayBox.js +22 -0
- package/src/components/atoms/display-box/DisplayBox.theme.js +9 -0
- package/src/components/atoms/display-box/index.js +3 -0
- package/src/components/atoms/display-card/DisplayCard.js +65 -0
- package/src/components/atoms/display-card/index.js +3 -0
- package/src/components/atoms/dropdown/Dropdown.js +299 -0
- package/src/components/atoms/dropdown/Dropdown.theme.js +9 -0
- package/src/components/atoms/dropdown/DropdownIcon.js +31 -0
- package/src/components/atoms/dropdown/index.js +3 -0
- package/src/components/atoms/form-layouts/FormContainer.js +28 -0
- package/src/components/atoms/form-layouts/FormInput.js +218 -0
- package/src/components/atoms/form-layouts/FormInputColumn.js +15 -0
- package/src/components/atoms/form-layouts/FormInputRow.js +26 -0
- package/src/components/atoms/form-layouts/FormLayouts.theme.js +52 -0
- package/src/components/atoms/form-layouts/index.js +6 -0
- package/src/components/atoms/form-select/FormSelect.js +62 -0
- package/src/components/atoms/form-select/FormSelect.styled.js +65 -0
- package/src/components/atoms/form-select/index.js +3 -0
- package/src/components/atoms/formatted-address/FormattedAddress.js +53 -0
- package/src/components/atoms/formatted-address/FormattedAddress.theme.js +11 -0
- package/src/components/atoms/formatted-address/index.js +3 -0
- package/src/components/atoms/hamburger-button/HamburgerButton.js +113 -0
- package/src/components/atoms/hamburger-button/index.js +3 -0
- package/src/components/atoms/heading/Heading.js +37 -0
- package/src/components/atoms/heading/Heading.styled.js +14 -0
- package/src/components/atoms/heading/Heading.theme.js +18 -0
- package/src/components/atoms/heading/index.js +3 -0
- package/src/components/atoms/icons/AccountsAddIcon.js +42 -0
- package/src/components/atoms/icons/AccountsIcon.js +37 -0
- package/src/components/atoms/icons/AccountsIconSmall.js +63 -0
- package/src/components/atoms/icons/ChevronIcon.js +51 -0
- package/src/components/atoms/icons/ForgotPasswordIcon.js +46 -0
- package/src/components/atoms/icons/GoToEmailIcon.js +31 -0
- package/src/components/atoms/icons/Icons.theme.js +38 -0
- package/src/components/atoms/icons/PaymentMethodIcon.js +42 -0
- package/src/components/atoms/icons/PaymentsIconSmall.js +63 -0
- package/src/components/atoms/icons/ProfileIconSmall.js +44 -0
- package/src/components/atoms/icons/PropertiesAddIcon.js +70 -0
- package/src/components/atoms/icons/PropertiesIconSmall.js +32 -0
- package/src/components/atoms/icons/SettingsIconSmall.js +63 -0
- package/src/components/atoms/icons/VerifiedEmailIcon.js +53 -0
- package/src/components/atoms/icons/index.js +28 -0
- package/src/components/atoms/index.js +33 -0
- package/src/components/atoms/labeled-amount/LabeledAmount.js +35 -0
- package/src/components/atoms/labeled-amount/LabeledAmount.theme.js +10 -0
- package/src/components/atoms/labeled-amount/index.js +3 -0
- package/src/components/atoms/layouts/Box.js +83 -0
- package/src/components/atoms/layouts/Box.styled.js +131 -0
- package/src/components/atoms/layouts/Center.js +28 -0
- package/src/components/atoms/layouts/Center.styled.js +18 -0
- package/src/components/atoms/layouts/Cluster.js +37 -0
- package/src/components/atoms/layouts/Cluster.styled.js +21 -0
- package/src/components/atoms/layouts/Cover.js +49 -0
- package/src/components/atoms/layouts/Cover.styled.js +29 -0
- package/src/components/atoms/layouts/Frame.js +28 -0
- package/src/components/atoms/layouts/Frame.styled.js +27 -0
- package/src/components/atoms/layouts/Grid.js +38 -0
- package/src/components/atoms/layouts/Grid.styled.js +22 -0
- package/src/components/atoms/layouts/Imposter.js +52 -0
- package/src/components/atoms/layouts/Imposter.styled.js +19 -0
- package/src/components/atoms/layouts/Motion.js +51 -0
- package/src/components/atoms/layouts/Motion.styled.js +41 -0
- package/src/components/atoms/layouts/Reel.js +28 -0
- package/src/components/atoms/layouts/Reel.styled.js +17 -0
- package/src/components/atoms/layouts/Sidebar.js +42 -0
- package/src/components/atoms/layouts/Sidebar.styled.js +38 -0
- package/src/components/atoms/layouts/Stack.js +36 -0
- package/src/components/atoms/layouts/Stack.styled.js +30 -0
- package/src/components/atoms/layouts/Switcher.js +64 -0
- package/src/components/atoms/layouts/Switcher.styled.js +44 -0
- package/src/components/atoms/layouts/examples/FixedSizeContainer.js +22 -0
- package/src/components/atoms/layouts/examples/FixedSizeContainer.styled.js +20 -0
- package/src/components/atoms/layouts/examples/LayoutContentBlock.js +27 -0
- package/src/components/atoms/layouts/examples/LayoutContentBlock.styled.js +15 -0
- package/src/components/atoms/layouts/examples/ResizingContainer.js +49 -0
- package/src/components/atoms/layouts/examples/ResizingContainer.styled.js +39 -0
- package/src/components/atoms/layouts/examples/cluster-example/ClusterExample.js +10 -0
- package/src/components/atoms/layouts/examples/cluster-example/ClusterExample.stories.js +97 -0
- package/src/components/atoms/layouts/examples/grid-example/GridExample.js +49 -0
- package/src/components/atoms/layouts/examples/grid-example/GridExample.stories.js +44 -0
- package/src/components/atoms/layouts/examples/sidebar-example/SidebarExample.js +11 -0
- package/src/components/atoms/layouts/examples/sidebar-example/SidebarExample.stories.js +87 -0
- package/src/components/atoms/layouts/examples/stack-example/StackExample.js +27 -0
- package/src/components/atoms/layouts/examples/stack-example/StackExample.stories.js +69 -0
- package/src/components/atoms/layouts/examples/switcher-example/SwitcherExample.js +38 -0
- package/src/components/atoms/layouts/examples/switcher-example/SwitcherExample.stories.js +65 -0
- package/src/components/atoms/layouts/index.js +27 -0
- package/src/components/atoms/line-item/LineItem.js +30 -0
- package/src/components/atoms/line-item/LineItem.theme.js +7 -0
- package/src/components/atoms/line-item/index.js +3 -0
- package/src/components/atoms/link/ExternalLink.js +50 -0
- package/src/components/atoms/link/ExternalLink.styled.js +26 -0
- package/src/components/atoms/link/InternalLink.js +51 -0
- package/src/components/atoms/link/InternalLink.styled.js +39 -0
- package/src/components/atoms/link/Link.theme.js +8 -0
- package/src/components/atoms/link/index.js +4 -0
- package/src/components/atoms/nav-footer/NavFooter.js +57 -0
- package/src/components/atoms/nav-footer/index.js +3 -0
- package/src/components/atoms/nav-header/NavHeader.js +36 -0
- package/src/components/atoms/nav-header/index.js +3 -0
- package/src/components/atoms/paragraph/Paragraph.js +31 -0
- package/src/components/atoms/paragraph/Paragraph.styled.js +13 -0
- package/src/components/atoms/paragraph/Paragraph.theme.js +18 -0
- package/src/components/atoms/paragraph/index.js +3 -0
- package/src/components/atoms/password-requirements/PasswordRequirements.js +116 -0
- package/src/components/atoms/password-requirements/index.js +3 -0
- package/src/components/atoms/placeholder/Placeholder.js +122 -0
- package/src/components/atoms/placeholder/Placeholder.theme.js +9 -0
- package/src/components/atoms/placeholder/index.js +3 -0
- package/src/components/atoms/processing-fee/ProcessingFee.js +43 -0
- package/src/components/atoms/processing-fee/ProcessingFee.theme.js +7 -0
- package/src/components/atoms/processing-fee/index.js +3 -0
- package/src/components/atoms/radio-button/RadioButton.js +101 -0
- package/src/components/atoms/radio-button/RadioButton.theme.js +9 -0
- package/src/components/atoms/radio-button/index.js +3 -0
- package/src/components/atoms/solid-divider/SolidDivider.js +22 -0
- package/src/components/atoms/solid-divider/SolidDivider.theme.js +8 -0
- package/src/components/atoms/solid-divider/index.js +3 -0
- package/src/components/atoms/spinner/Spinner.js +61 -0
- package/src/components/atoms/spinner/Spinner.theme.js +5 -0
- package/src/components/atoms/spinner/index.js +3 -0
- package/src/components/atoms/state-province-dropdown/StateProvinceDropdown.js +28 -0
- package/src/components/atoms/state-province-dropdown/index.js +3 -0
- package/src/components/atoms/state-province-dropdown/options.js +3837 -0
- package/src/components/atoms/text/Text.js +37 -0
- package/src/components/atoms/text/Text.styled.js +32 -0
- package/src/components/atoms/text/Text.theme.js +22 -0
- package/src/components/atoms/text/index.js +3 -0
- package/src/components/atoms/toggle-switch/ToggleSwitch.js +212 -0
- package/src/components/atoms/toggle-switch/ToggleSwitch.theme.js +36 -0
- package/src/components/atoms/toggle-switch/index.js +3 -0
- package/src/components/index.js +3 -0
- package/src/components/molecules/address-form/AddressForm.js +110 -0
- package/src/components/molecules/address-form/AddressForm.state.js +52 -0
- package/src/components/molecules/address-form/index.js +11 -0
- package/src/components/molecules/change-password-form/ChangePasswordForm.js +92 -0
- package/src/components/molecules/change-password-form/ChangePasswordForm.state.js +33 -0
- package/src/components/molecules/change-password-form/index.js +11 -0
- package/src/components/molecules/collapsible-section/CollapsibleSection.js +126 -0
- package/src/components/molecules/collapsible-section/CollapsibleSection.theme.js +11 -0
- package/src/components/molecules/collapsible-section/index.js +3 -0
- package/src/components/molecules/edit-name-form/EditNameForm.js +51 -0
- package/src/components/molecules/edit-name-form/EditNameForm.state.js +14 -0
- package/src/components/molecules/edit-name-form/index.js +11 -0
- package/src/components/molecules/email-form/EmailForm.js +55 -0
- package/src/components/molecules/email-form/EmailForm.state.js +19 -0
- package/src/components/molecules/email-form/index.js +11 -0
- package/src/components/molecules/forgot-password-form/ForgotPasswordForm.js +32 -0
- package/src/components/molecules/forgot-password-form/ForgotPasswordForm.state.js +11 -0
- package/src/components/molecules/forgot-password-form/index.js +11 -0
- package/src/components/molecules/highlight-tab-row/HighlightTabRow.js +62 -0
- package/src/components/molecules/highlight-tab-row/HighlightTabRow.theme.js +7 -0
- package/src/components/molecules/highlight-tab-row/index.js +8 -0
- package/src/components/molecules/index.js +24 -0
- package/src/components/molecules/login-form/LoginForm.js +46 -0
- package/src/components/molecules/login-form/LoginForm.state.js +14 -0
- package/src/components/molecules/login-form/index.js +11 -0
- package/src/components/molecules/modal/Modal.js +138 -0
- package/src/components/molecules/modal/index.js +3 -0
- package/src/components/molecules/module/Module.js +42 -0
- package/src/components/molecules/module/Module.theme.js +30 -0
- package/src/components/molecules/module/index.js +8 -0
- package/src/components/molecules/nav-menu/NavMenu.theme.js +5 -0
- package/src/components/molecules/nav-menu/NavMenuDesktop.js +39 -0
- package/src/components/molecules/nav-menu/NavMenuMobile.js +63 -0
- package/src/components/molecules/nav-menu/index.js +4 -0
- package/src/components/molecules/obligation/Obligation.js +69 -0
- package/src/components/molecules/obligation/icons/AccountBillIcon.js +89 -0
- package/src/components/molecules/obligation/icons/AccountConstructionIcon.js +99 -0
- package/src/components/molecules/obligation/icons/AccountDentalIcon.js +94 -0
- package/src/components/molecules/obligation/icons/AccountElectricIcon.js +99 -0
- package/src/components/molecules/obligation/icons/AccountGarbageIcon.js +94 -0
- package/src/components/molecules/obligation/icons/AccountGasIcon.js +94 -0
- package/src/components/molecules/obligation/icons/AccountGenericIcon.js +89 -0
- package/src/components/molecules/obligation/icons/AccountMedicalIcon.js +94 -0
- package/src/components/molecules/obligation/icons/AccountWaterIcon.js +94 -0
- package/src/components/molecules/obligation/icons/PropertyApartmentIcon.js +99 -0
- package/src/components/molecules/obligation/icons/PropertyBusinessIcon.js +94 -0
- package/src/components/molecules/obligation/icons/PropertyCarIcon.js +99 -0
- package/src/components/molecules/obligation/icons/PropertyCommercialVehicleIcon.js +100 -0
- package/src/components/molecules/obligation/icons/PropertyGarageIcon.js +96 -0
- package/src/components/molecules/obligation/icons/PropertyLandIcon.js +99 -0
- package/src/components/molecules/obligation/icons/PropertyMotorcycleIcon.js +99 -0
- package/src/components/molecules/obligation/icons/PropertyPersonalIcon.js +94 -0
- package/src/components/molecules/obligation/icons/PropertyStorefrontIcon.js +100 -0
- package/src/components/molecules/obligation/icons/index.js +60 -0
- package/src/components/molecules/obligation/index.js +3 -0
- package/src/components/molecules/obligation/modules/AmountModule.js +36 -0
- package/src/components/molecules/obligation/modules/IconModule.js +29 -0
- package/src/components/molecules/obligation/modules/PaymentDetailsActions.js +67 -0
- package/src/components/molecules/obligation/modules/TitleModule.js +25 -0
- package/src/components/molecules/obligation/modules/index.js +6 -0
- package/src/components/molecules/payment-button-bar/PaymentButtonBar.js +80 -0
- package/src/components/molecules/payment-button-bar/index.js +3 -0
- package/src/components/molecules/payment-details/PaymentDetails.js +158 -0
- package/src/components/molecules/payment-details/PaymentDetails.theme.js +11 -0
- package/src/components/molecules/payment-details/index.js +1 -0
- package/src/components/molecules/phone-form/PhoneForm.js +44 -0
- package/src/components/molecules/phone-form/PhoneForm.state.js +17 -0
- package/src/components/molecules/phone-form/index.js +11 -0
- package/src/components/molecules/radio-section/RadioSection.js +205 -0
- package/src/components/molecules/radio-section/RadioSection.theme.js +15 -0
- package/src/components/molecules/radio-section/index.js +3 -0
- package/src/components/molecules/registration-form/RegistrationForm.js +104 -0
- package/src/components/molecules/registration-form/RegistrationForm.state.js +40 -0
- package/src/components/molecules/registration-form/index.js +11 -0
- package/src/components/molecules/reset-confirmation-form/ResetConfirmationForm.js +56 -0
- package/src/components/molecules/reset-confirmation-form/index.js +3 -0
- package/src/components/molecules/reset-password-form/ResetPasswordForm.js +67 -0
- package/src/components/molecules/reset-password-form/ResetPasswordForm.state.js +30 -0
- package/src/components/molecules/reset-password-form/index.js +11 -0
- package/src/components/molecules/reset-password-success/ResetPasswordSuccess.js +55 -0
- package/src/components/molecules/reset-password-success/index.js +3 -0
- package/src/components/molecules/tab-sidebar/TabSidebar.js +92 -0
- package/src/components/molecules/tab-sidebar/TabSidebar.theme.js +9 -0
- package/src/components/molecules/tab-sidebar/index.js +3 -0
- package/src/components/molecules/terms-and-conditions/TermsAndConditions.js +73 -0
- package/src/components/molecules/terms-and-conditions/index.js +3 -0
- package/src/components/molecules/terms-and-conditions-modal/TermsAndConditionsModal.js +64 -0
- package/src/components/molecules/terms-and-conditions-modal/TermsAndConditionsModal.theme.js +28 -0
- package/src/components/molecules/terms-and-conditions-modal/index.js +3 -0
- package/src/components/molecules/workflow-tile/WorkflowTile.js +58 -0
- package/src/components/molecules/workflow-tile/index.js +3 -0
- package/src/components/templates/center-single/CenterSingle.js +61 -0
- package/src/components/templates/center-single/index.js +3 -0
- package/src/components/templates/center-stack/CenterStack.js +49 -0
- package/src/components/templates/center-stack/index.js +3 -0
- package/src/components/templates/default-page-template/DefaultPageTemplate.js +49 -0
- package/src/components/templates/default-page-template/index.js +3 -0
- package/src/components/templates/index.js +5 -0
- package/src/components/templates/sidebar-single-content/SidebarSingleContent.js +60 -0
- package/src/components/templates/sidebar-single-content/index.js +3 -0
- package/src/components/templates/sidebar-stack-content/SidebarStackContent.js +81 -0
- package/src/components/templates/sidebar-stack-content/index.js +3 -0
- package/src/components/templates/templates.theme.js +5 -0
- package/src/components/withWindowSize.js +50 -0
- package/src/constants/colors.js +178 -0
- package/src/constants/regex_constants.js +1 -0
- package/src/constants/style_constants.js +21 -0
- package/src/deprecated/colors.js +154 -0
- package/src/deprecated/components/radio-button/index.js +3 -0
- package/src/deprecated/components/radio-button/radio-button.js +44 -0
- package/src/deprecated/icons/AlertErrorIcon.js +42 -0
- package/src/deprecated/icons/AlertInfoIcon.js +42 -0
- package/src/deprecated/icons/AlertSuccessIcon.js +42 -0
- package/src/deprecated/icons/AlertWarningIcon.js +36 -0
- package/src/deprecated/icons/BankIcon.js +82 -0
- package/src/deprecated/icons/GenericCard.js +39 -0
- package/src/deprecated/icons/IconAdd.js +44 -0
- package/src/deprecated/icons/IconCheck.js +23 -0
- package/src/deprecated/icons/IconCheckEmail.js +46 -0
- package/src/deprecated/icons/IconChevron.js +35 -0
- package/src/deprecated/icons/IconEmailVerified.js +62 -0
- package/src/deprecated/icons/IconEye.js +32 -0
- package/src/deprecated/icons/IconEyeSlash.js +48 -0
- package/src/deprecated/icons/IconInvalid.js +69 -0
- package/src/deprecated/icons/IconNeutral.js +27 -0
- package/src/deprecated/icons/IconQuit.js +32 -0
- package/src/deprecated/icons/IconValid.js +72 -0
- package/src/deprecated/icons/IconWarn.js +28 -0
- package/src/deprecated/icons/index.js +40 -0
- package/src/deprecated/index.js +1 -0
- package/src/deprecated/spinner/Spinner.js +68 -0
- package/src/deprecated/spinner/index.js +1 -0
- package/src/deprecated/utility/__tests__/safeConcat.spec.js +59 -0
- package/src/deprecated/utility/__tests__/validateKeyType.spec.js +116 -0
- package/src/deprecated/utility/index.js +2 -0
- package/src/deprecated/utility/safeConcat.js +10 -0
- package/src/deprecated/utility/validateKeyType.js +19 -0
- package/src/index.js +2 -0
- package/src/util/formats.js +30 -0
- package/src/util/general.js +15 -0
- package/src/util/inputValidationUtils.js +257 -0
- package/src/util/router-utils.js +23 -0
- package/src/util/themeUtils.js +144 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { fallbackValues } from "./LabeledAmount.theme";
|
|
3
|
+
import { themeComponent } from "../../../util/themeUtils";
|
|
4
|
+
import { Stack } from "../layouts";
|
|
5
|
+
import Heading from "../heading";
|
|
6
|
+
import Paragraph from "../paragraph";
|
|
7
|
+
|
|
8
|
+
const LabeledAmount = ({ variant = "pL", label, amount, themeValues }) => {
|
|
9
|
+
const LabeledAmountText = variant === "h6" ? Heading : Paragraph;
|
|
10
|
+
return (
|
|
11
|
+
<Stack direction="row">
|
|
12
|
+
<LabeledAmountText
|
|
13
|
+
variant={variant}
|
|
14
|
+
weight={themeValues.fontWeight}
|
|
15
|
+
extraStyles="text-align: end; flex: 3;"
|
|
16
|
+
>
|
|
17
|
+
{label}:
|
|
18
|
+
</LabeledAmountText>
|
|
19
|
+
<LabeledAmountText
|
|
20
|
+
variant={variant}
|
|
21
|
+
weight={themeValues.fontWeight}
|
|
22
|
+
extraStyles="text-align: end; flex: 1;"
|
|
23
|
+
>
|
|
24
|
+
{amount}
|
|
25
|
+
</LabeledAmountText>
|
|
26
|
+
</Stack>
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default themeComponent(
|
|
31
|
+
LabeledAmount,
|
|
32
|
+
"LabeledAmount",
|
|
33
|
+
fallbackValues,
|
|
34
|
+
"default"
|
|
35
|
+
);
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import React, { Fragment } from "react";
|
|
2
|
+
import { BoxWrapper } from "./Box.styled";
|
|
3
|
+
import { safeChildren } from "../../../util/general";
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
Box component to create generic boxes
|
|
7
|
+
Supply padding, border, background, and color values
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const Box = ({
|
|
11
|
+
padding = "16px",
|
|
12
|
+
borderSize = "0px",
|
|
13
|
+
borderColor = "transparent",
|
|
14
|
+
borderRadius,
|
|
15
|
+
boxShadow = "none",
|
|
16
|
+
background,
|
|
17
|
+
color,
|
|
18
|
+
minHeight,
|
|
19
|
+
width,
|
|
20
|
+
minWidth,
|
|
21
|
+
maxWidth,
|
|
22
|
+
borderWidthOverride,
|
|
23
|
+
border,
|
|
24
|
+
textAlign,
|
|
25
|
+
hoverStyles,
|
|
26
|
+
focusStyles,
|
|
27
|
+
activeStyles,
|
|
28
|
+
disabledStyles,
|
|
29
|
+
variant,
|
|
30
|
+
as,
|
|
31
|
+
onClick,
|
|
32
|
+
onKeyDown,
|
|
33
|
+
onMouseEnter,
|
|
34
|
+
onMouseLeave,
|
|
35
|
+
onFocus,
|
|
36
|
+
onBlur,
|
|
37
|
+
onTouchEnd,
|
|
38
|
+
theme,
|
|
39
|
+
hiddenStyles,
|
|
40
|
+
extraStyles,
|
|
41
|
+
dataQa,
|
|
42
|
+
children,
|
|
43
|
+
...rest
|
|
44
|
+
}) => (
|
|
45
|
+
<BoxWrapper
|
|
46
|
+
padding={padding}
|
|
47
|
+
borderSize={borderSize}
|
|
48
|
+
borderColor={borderColor}
|
|
49
|
+
boxShadow={boxShadow}
|
|
50
|
+
color={color}
|
|
51
|
+
minHeight={minHeight}
|
|
52
|
+
width={width}
|
|
53
|
+
minWidth={minWidth}
|
|
54
|
+
maxWidth={maxWidth}
|
|
55
|
+
background={background}
|
|
56
|
+
borderRadius={borderRadius}
|
|
57
|
+
borderWidthOverride={borderWidthOverride}
|
|
58
|
+
border={border}
|
|
59
|
+
hoverStyles={hoverStyles}
|
|
60
|
+
focusStyles={focusStyles}
|
|
61
|
+
activeStyles={activeStyles}
|
|
62
|
+
disabledStyles={disabledStyles}
|
|
63
|
+
variant={variant}
|
|
64
|
+
as={as}
|
|
65
|
+
onClick={onClick}
|
|
66
|
+
hiddenStyles={hiddenStyles}
|
|
67
|
+
onKeyDown={onKeyDown}
|
|
68
|
+
extraStyles={extraStyles}
|
|
69
|
+
theme={theme}
|
|
70
|
+
textAlign={textAlign}
|
|
71
|
+
data-qa={dataQa}
|
|
72
|
+
onMouseEnter={onMouseEnter}
|
|
73
|
+
onMouseLeave={onMouseLeave}
|
|
74
|
+
onFocus={onFocus}
|
|
75
|
+
onBlur={onBlur}
|
|
76
|
+
onTouchEnd={onTouchEnd}
|
|
77
|
+
{...rest}
|
|
78
|
+
>
|
|
79
|
+
{safeChildren(children, <Fragment />)}
|
|
80
|
+
</BoxWrapper>
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
export default Box;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import styled, { css } from "styled-components";
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
The child span selector on hover styles targets the text inside of buttons when a button is hovered,
|
|
6
|
+
as long as the box wrapper has an "as" prop equal to "button"
|
|
7
|
+
|
|
8
|
+
The extracting of props and the disabling of the eslint rule is to stop React from complaining about
|
|
9
|
+
unrecognized DOM attributes.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/* eslint-disable no-unused-vars */
|
|
13
|
+
export const BoxWrapper = styled(
|
|
14
|
+
({
|
|
15
|
+
activeStyles,
|
|
16
|
+
focusStyles,
|
|
17
|
+
hoverStyles,
|
|
18
|
+
disabledStyles,
|
|
19
|
+
extraStyles,
|
|
20
|
+
borderSize,
|
|
21
|
+
borderColor,
|
|
22
|
+
borderWidthOverride,
|
|
23
|
+
borderRadius,
|
|
24
|
+
textAlign,
|
|
25
|
+
boxShadow,
|
|
26
|
+
minHeight,
|
|
27
|
+
minWidth,
|
|
28
|
+
maxWidth,
|
|
29
|
+
padding,
|
|
30
|
+
...props
|
|
31
|
+
}) => <div {...props} />
|
|
32
|
+
)`
|
|
33
|
+
position: relative;
|
|
34
|
+
box-sizing: border-box;
|
|
35
|
+
padding: ${({ padding }) => padding};
|
|
36
|
+
border: ${({ borderSize, borderColor }) =>
|
|
37
|
+
`${borderSize} solid ${borderColor}`};
|
|
38
|
+
box-shadow: ${({ boxShadow }) => boxShadow};
|
|
39
|
+
background-color: ${({ background }) => background};
|
|
40
|
+
min-height: ${({ minHeight }) => (minHeight ? minHeight : "auto")};
|
|
41
|
+
${({ width }) => width && `width: ${width};`}
|
|
42
|
+
min-width: ${({ minWidth }) => (minWidth ? minWidth : "auto")};
|
|
43
|
+
max-width: ${({ maxWidth }) => (maxWidth ? maxWidth : "auto")};
|
|
44
|
+
color: ${({ color }) => color};
|
|
45
|
+
border-radius: ${({ borderRadius }) => borderRadius};
|
|
46
|
+
border-width: ${({ borderWidthOverride, borderSize }) =>
|
|
47
|
+
borderWidthOverride ? borderWidthOverride : borderSize};
|
|
48
|
+
border: ${({ border }) => border};
|
|
49
|
+
text-align: ${({ textAlign }) => textAlign};
|
|
50
|
+
|
|
51
|
+
&:hover {
|
|
52
|
+
${({ hoverStyles, as }) =>
|
|
53
|
+
css`
|
|
54
|
+
${hoverStyles}
|
|
55
|
+
${as === "button"
|
|
56
|
+
? `> * > span {
|
|
57
|
+
${hoverStyles}
|
|
58
|
+
border: none;
|
|
59
|
+
outline: none;
|
|
60
|
+
box-shadow: none;
|
|
61
|
+
}`
|
|
62
|
+
: ``}
|
|
63
|
+
`}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
&:focus {
|
|
67
|
+
${({ focusStyles, as }) =>
|
|
68
|
+
css`
|
|
69
|
+
${focusStyles}
|
|
70
|
+
${as === "button"
|
|
71
|
+
? `> * > span {
|
|
72
|
+
${focusStyles}
|
|
73
|
+
border: none;
|
|
74
|
+
outline: none;
|
|
75
|
+
box-shadow: none;
|
|
76
|
+
}`
|
|
77
|
+
: ``}
|
|
78
|
+
`}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
&:active {
|
|
82
|
+
${({ activeStyles, as }) =>
|
|
83
|
+
css`
|
|
84
|
+
${activeStyles}
|
|
85
|
+
${as === "button"
|
|
86
|
+
? ` > * > span {
|
|
87
|
+
${activeStyles}
|
|
88
|
+
border: none;
|
|
89
|
+
outline: none;
|
|
90
|
+
box-shadow: none;
|
|
91
|
+
}`
|
|
92
|
+
: ``}
|
|
93
|
+
`}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
&:disabled {
|
|
97
|
+
${({ disabledStyles, as }) =>
|
|
98
|
+
css`
|
|
99
|
+
${disabledStyles}
|
|
100
|
+
${as === "button"
|
|
101
|
+
? ` > * > span {
|
|
102
|
+
${disabledStyles}
|
|
103
|
+
border: none;
|
|
104
|
+
outline: none;
|
|
105
|
+
box-shadow: none;
|
|
106
|
+
}`
|
|
107
|
+
: ``}
|
|
108
|
+
`}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
& * {
|
|
112
|
+
color: ${({ color }) => color};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
${({ hiddenStyles }) =>
|
|
116
|
+
hiddenStyles &&
|
|
117
|
+
css`
|
|
118
|
+
display: none;
|
|
119
|
+
`}
|
|
120
|
+
${({ extraStyles }) =>
|
|
121
|
+
css`
|
|
122
|
+
${extraStyles}
|
|
123
|
+
`}
|
|
124
|
+
|
|
125
|
+
${({ hiddenStyles }) =>
|
|
126
|
+
hiddenStyles &&
|
|
127
|
+
css`
|
|
128
|
+
display: none;
|
|
129
|
+
`}
|
|
130
|
+
`;
|
|
131
|
+
/* eslint-enable no-unused-vars */
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React, { Fragment } from "react";
|
|
2
|
+
import { CenterWrapper } from "./Center.styled";
|
|
3
|
+
import { safeChildren } from "../../../util/general";
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
Component to horizontally center itself (with auto right and left margins)
|
|
7
|
+
Use intrinsic prop if you want its children that are narrower than the max-width
|
|
8
|
+
to also be centered within the center wrapper itself
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const Center = ({
|
|
12
|
+
maxWidth,
|
|
13
|
+
gutters,
|
|
14
|
+
intrinsic = false,
|
|
15
|
+
children,
|
|
16
|
+
...rest
|
|
17
|
+
}) => (
|
|
18
|
+
<CenterWrapper
|
|
19
|
+
maxWidth={maxWidth}
|
|
20
|
+
gutters={gutters}
|
|
21
|
+
intrinsic={intrinsic}
|
|
22
|
+
{...rest}
|
|
23
|
+
>
|
|
24
|
+
{safeChildren(children, <Fragment />)}
|
|
25
|
+
</CenterWrapper>
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
export default Center;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
|
|
3
|
+
export const CenterWrapper = styled.div`
|
|
4
|
+
box-sizing: content-box;
|
|
5
|
+
margin-left: auto;
|
|
6
|
+
margin-right: auto;
|
|
7
|
+
max-width: ${({ maxWidth }) => maxWidth};
|
|
8
|
+
padding-left: ${({ gutters }) => gutters};
|
|
9
|
+
padding-right: ${({ gutters }) => gutters};
|
|
10
|
+
${({ intrinsic }) =>
|
|
11
|
+
intrinsic
|
|
12
|
+
? `
|
|
13
|
+
display: flex;
|
|
14
|
+
flex-direction: column;
|
|
15
|
+
align-items: center;
|
|
16
|
+
`
|
|
17
|
+
: ``};
|
|
18
|
+
`;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React, { Fragment } from "react";
|
|
2
|
+
import { ClusterWrapper, ClusterInnerWrapper } from "./Cluster.styled";
|
|
3
|
+
import { safeChildren } from "../../../util/general";
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
Cluster components suit any groups of elements that differ in
|
|
7
|
+
length and are liable to wrap. Buttons that appear together at the
|
|
8
|
+
end of forms are ideal candidates, as well as lists of tags
|
|
9
|
+
keywords, or other meta information. Use the Cluster to align any
|
|
10
|
+
groups of horizontally laid out elements to the left or right, or
|
|
11
|
+
in the center.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
const Cluster = ({
|
|
15
|
+
justify,
|
|
16
|
+
align,
|
|
17
|
+
childGap,
|
|
18
|
+
minHeight,
|
|
19
|
+
minWidth,
|
|
20
|
+
overflow = false,
|
|
21
|
+
children,
|
|
22
|
+
...rest
|
|
23
|
+
}) => (
|
|
24
|
+
<ClusterWrapper overflow={overflow} {...rest}>
|
|
25
|
+
<ClusterInnerWrapper
|
|
26
|
+
justify={justify}
|
|
27
|
+
align={align}
|
|
28
|
+
childGap={childGap}
|
|
29
|
+
minHeight={minHeight}
|
|
30
|
+
minWidth={minWidth}
|
|
31
|
+
>
|
|
32
|
+
{safeChildren(children, <Fragment />)}
|
|
33
|
+
</ClusterInnerWrapper>
|
|
34
|
+
</ClusterWrapper>
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
export default Cluster;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
|
|
3
|
+
export const ClusterWrapper = styled.div`
|
|
4
|
+
overflow: ${({ overflow }) => (overflow ? "visible" : "hidden")};
|
|
5
|
+
box-sizing: border-box;
|
|
6
|
+
`;
|
|
7
|
+
|
|
8
|
+
export const ClusterInnerWrapper = styled.div`
|
|
9
|
+
box-sizing: border-box;
|
|
10
|
+
display: flex;
|
|
11
|
+
flex-wrap: wrap;
|
|
12
|
+
justify-content: ${({ justify }) => justify};
|
|
13
|
+
align-items: ${({ align }) => align};
|
|
14
|
+
margin: calc(${({ childGap }) => childGap} / 2 * -1);
|
|
15
|
+
min-height: ${({ minHeight }) => minHeight};
|
|
16
|
+
min-width: ${({ minWidth }) => minWidth};
|
|
17
|
+
|
|
18
|
+
> * {
|
|
19
|
+
margin: calc(${({ childGap }) => childGap} / 2);
|
|
20
|
+
}
|
|
21
|
+
`;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React, { Fragment } from "react";
|
|
2
|
+
import { safeChildren } from "../../../util/general";
|
|
3
|
+
import { CoverOuterContainer } from "./Cover.styled";
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
The Cover component is used when you want to have one center element
|
|
7
|
+
and an optional top/header element and/or an optional bottom/footer element.
|
|
8
|
+
The classic use case is for an "above the fold" page layout in which you have a header, footer, and center content of variable size. When the center content is smaller than
|
|
9
|
+
minHeight, the cover expands to minHeight and centers the content, while anchoring
|
|
10
|
+
the optional top element to the top, and the optional bottom element to the bottom.
|
|
11
|
+
|
|
12
|
+
If the center content is taller than minHeight, then the entire cover exapnds, while
|
|
13
|
+
still anchorhing the top and bottom elements where they belong.
|
|
14
|
+
|
|
15
|
+
Note: This component is only concerned with vertical centering. To also
|
|
16
|
+
horizontally center your content, combine it with the Center component.
|
|
17
|
+
Therefore childGap only sets vertical margins in this component.
|
|
18
|
+
|
|
19
|
+
Props:
|
|
20
|
+
fillCenter:
|
|
21
|
+
If true instead of centering the middle content it will grow to fill the space
|
|
22
|
+
WARNING: May act unexpectedly if children have flex-grow property on them
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const Cover = ({
|
|
26
|
+
minHeight = "100vh",
|
|
27
|
+
childGap,
|
|
28
|
+
padding,
|
|
29
|
+
fillCenter,
|
|
30
|
+
singleChild,
|
|
31
|
+
centerOverride,
|
|
32
|
+
children,
|
|
33
|
+
...rest
|
|
34
|
+
}) => (
|
|
35
|
+
<CoverOuterContainer
|
|
36
|
+
minHeight={minHeight}
|
|
37
|
+
padding={padding}
|
|
38
|
+
childGap={childGap}
|
|
39
|
+
centerOverride={centerOverride}
|
|
40
|
+
fillCenter={fillCenter}
|
|
41
|
+
{...rest}
|
|
42
|
+
>
|
|
43
|
+
{singleChild ? <div /> : <Fragment />}
|
|
44
|
+
{safeChildren(children, <Fragment />)}
|
|
45
|
+
{singleChild ? <div /> : <Fragment />}
|
|
46
|
+
</CoverOuterContainer>
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
export default Cover;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
|
|
3
|
+
export const CoverOuterContainer = styled.div`
|
|
4
|
+
box-sizing: border-box;
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
min-height: ${({ minHeight }) => minHeight};
|
|
8
|
+
padding: ${({ padding }) => padding};
|
|
9
|
+
|
|
10
|
+
> * {
|
|
11
|
+
margin-top: ${({ childGap }) => childGap};
|
|
12
|
+
margin-bottom: ${({ childGap }) => childGap};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
> :first-child {
|
|
16
|
+
margin-top: 0;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
${({ fillCenter }) => (fillCenter ? "> :nth-child(2) {flex-grow: 1;}" : "")}
|
|
20
|
+
|
|
21
|
+
${({ centerOverride }) =>
|
|
22
|
+
centerOverride
|
|
23
|
+
? `> :nth-child(2) {margin-top: 0; margin-bottom: auto;}`
|
|
24
|
+
: `> :nth-child(2) {margin-top: auto; margin-bottom: auto;}`}
|
|
25
|
+
|
|
26
|
+
> :last-child {
|
|
27
|
+
margin-bottom: 0;
|
|
28
|
+
}
|
|
29
|
+
`;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React, { Fragment } from "react";
|
|
2
|
+
import { safeChildren } from "../../../util/general";
|
|
3
|
+
import { FrameOuterContainer } from "./Frame.styled";
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
The Frame component is used for cropping content to a specific aspect ratio.
|
|
7
|
+
The aspect ratio is supplied by the numerator and denominator props.
|
|
8
|
+
(The numerator is the left-hand number and denominator the right-hand number
|
|
9
|
+
in class aspect-ratio notation, e.g., 16:9 or 4:3).
|
|
10
|
+
|
|
11
|
+
This component should mostly be used with images or video content.
|
|
12
|
+
However, the CSS makes it possible to use with _any_ type of element.
|
|
13
|
+
This is useful for a situation where your child may be an image, or may be
|
|
14
|
+
a different type of element. A good example is having textual fallback
|
|
15
|
+
content when an image is not available.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
const Frame = ({ numerator = 1, denominator = 1, children, ...rest }) => (
|
|
19
|
+
<FrameOuterContainer
|
|
20
|
+
numerator={numerator}
|
|
21
|
+
denominator={denominator}
|
|
22
|
+
{...rest}
|
|
23
|
+
>
|
|
24
|
+
{safeChildren(children, <Fragment />)}
|
|
25
|
+
</FrameOuterContainer>
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
export default Frame;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
|
|
3
|
+
export const FrameOuterContainer = styled.div`
|
|
4
|
+
box-sizing: border-box;
|
|
5
|
+
padding-bottom: ${({ numerator, denominator }) =>
|
|
6
|
+
`calc((${numerator} / ${denominator}) * 100%)`};
|
|
7
|
+
position: relative;
|
|
8
|
+
|
|
9
|
+
> * {
|
|
10
|
+
overflow: hidden;
|
|
11
|
+
position: absolute;
|
|
12
|
+
top: 0;
|
|
13
|
+
right: 0;
|
|
14
|
+
bottom: 0;
|
|
15
|
+
left: 0;
|
|
16
|
+
display: flex;
|
|
17
|
+
justify-content: center;
|
|
18
|
+
align-items: center;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
> img,
|
|
22
|
+
> video {
|
|
23
|
+
width: 100%;
|
|
24
|
+
height: 100%;
|
|
25
|
+
object-fit: cover;
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React, { useRef, useState, useLayoutEffect, Fragment } from "react";
|
|
2
|
+
import { GridWrapper } from "./Grid.styled";
|
|
3
|
+
import { safeChildren } from "../../../util/general";
|
|
4
|
+
|
|
5
|
+
const Grid = ({
|
|
6
|
+
columnGap,
|
|
7
|
+
minColWidth = 20,
|
|
8
|
+
maxColWidth = "1fr",
|
|
9
|
+
children,
|
|
10
|
+
...rest
|
|
11
|
+
}) => {
|
|
12
|
+
const ref = useRef();
|
|
13
|
+
const [width, setWidth] = useState(0);
|
|
14
|
+
const [aboveMin, setAboveMin] = useState(true);
|
|
15
|
+
useLayoutEffect(() => {
|
|
16
|
+
const currentWidth = ref.current.getBoundingClientRect().width;
|
|
17
|
+
setWidth(currentWidth);
|
|
18
|
+
setAboveMin(currentWidth >= minColWidth * 16);
|
|
19
|
+
}, [ref.current, width]);
|
|
20
|
+
return (
|
|
21
|
+
<GridWrapper
|
|
22
|
+
ref={ref}
|
|
23
|
+
columnGap={columnGap}
|
|
24
|
+
aboveMin={aboveMin}
|
|
25
|
+
minColWidth={
|
|
26
|
+
typeof minColWidth === "number" ? `${minColWidth}rem` : minColWidth
|
|
27
|
+
}
|
|
28
|
+
maxColWidth={
|
|
29
|
+
typeof maxColWidth === "number" ? `${maxColWidth}rem` : maxColWidth
|
|
30
|
+
}
|
|
31
|
+
{...rest}
|
|
32
|
+
>
|
|
33
|
+
{safeChildren(children, <Fragment />)}
|
|
34
|
+
</GridWrapper>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default Grid;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
|
|
3
|
+
export const GridWrapper = styled.div`
|
|
4
|
+
display: grid;
|
|
5
|
+
grid-gap: ${({ columnGap }) => columnGap};
|
|
6
|
+
grid-template-columns: ${({ aboveMin, minColWidth, maxColWidth }) =>
|
|
7
|
+
aboveMin
|
|
8
|
+
? `repeat(auto-fill, minmax(${minColWidth}, ${maxColWidth}))`
|
|
9
|
+
: "100%"};
|
|
10
|
+
|
|
11
|
+
@supports (width: min(${({ minColWidth }) => minColWidth}, 100%)) {
|
|
12
|
+
& {
|
|
13
|
+
grid-template-columns: repeat(
|
|
14
|
+
auto-fill,
|
|
15
|
+
minmax(
|
|
16
|
+
${({ minColWidth }) => minColWidth},
|
|
17
|
+
${({ maxColWidth }) => maxColWidth}
|
|
18
|
+
)
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
`;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React, { Fragment } from "react";
|
|
2
|
+
import { ImposterWrapper } from "./Imposter.styled";
|
|
3
|
+
import { safeChildren } from "../../../util/general";
|
|
4
|
+
|
|
5
|
+
/*
|
|
6
|
+
The imposter is used to position content over a parent node.
|
|
7
|
+
Great for tooltips, modals, dialogs, etc.
|
|
8
|
+
For this to work, the parent *must* have position: relative in it styles.
|
|
9
|
+
If using a <Box /> component, this can be specified using the extraStyles prop.
|
|
10
|
+
|
|
11
|
+
Imposter takes a few props:
|
|
12
|
+
-fixed (defaults to false): if true, position imposter relative to the viewport, not its parent
|
|
13
|
+
-verticalMargin (defaults to "0px"): space between edge of imposter and edge of its parent
|
|
14
|
+
-horizontalMargin (defaults to "0px"): space between edge of imposter and edge of its parent
|
|
15
|
+
-breakout (defaults to true): if false, contain imposter within parent. margins do not apply if breakout is true.
|
|
16
|
+
-top (defaults to 50%): position from top of parent element
|
|
17
|
+
-left (defaults to 50%): position from left of parent element
|
|
18
|
+
-centered (defaults to false): if true, applies a transform such that the center of the imposter is
|
|
19
|
+
over the center of the parent element
|
|
20
|
+
|
|
21
|
+
NOTE: Imposter is not accessible by default. If building a modal/dialog/tooltip, make sure your content has the appropriate aria-roles and is focusable via keyboard.
|
|
22
|
+
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const Imposter = ({
|
|
26
|
+
fixed = false,
|
|
27
|
+
verticalMargin = "0px",
|
|
28
|
+
horizontalMargin = "0px",
|
|
29
|
+
breakout = true,
|
|
30
|
+
top = "50%",
|
|
31
|
+
left = "50%",
|
|
32
|
+
centered = false,
|
|
33
|
+
visible = true,
|
|
34
|
+
children,
|
|
35
|
+
...rest
|
|
36
|
+
}) => (
|
|
37
|
+
<ImposterWrapper
|
|
38
|
+
fixed={fixed}
|
|
39
|
+
verticalMargin={verticalMargin}
|
|
40
|
+
horizontalMargin={horizontalMargin}
|
|
41
|
+
breakout={breakout}
|
|
42
|
+
top={top}
|
|
43
|
+
left={left}
|
|
44
|
+
centered={centered}
|
|
45
|
+
visible={visible}
|
|
46
|
+
{...rest}
|
|
47
|
+
>
|
|
48
|
+
{safeChildren(children, <Fragment />)}
|
|
49
|
+
</ImposterWrapper>
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
export default Imposter;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
|
|
3
|
+
export const ImposterWrapper = styled.div`
|
|
4
|
+
position: ${({ fixed }) => (fixed ? "fixed" : "absolute")};
|
|
5
|
+
top: ${({ top }) => top};
|
|
6
|
+
left: ${({ left }) => left};
|
|
7
|
+
display: ${({ visible }) => (visible ? "block" : "none")};
|
|
8
|
+
|
|
9
|
+
${({ centered }) => (centered ? `transform: translate(-50%, -50%);` : ``)}
|
|
10
|
+
|
|
11
|
+
${({ breakout, verticalMargin, horizontalMargin }) =>
|
|
12
|
+
breakout
|
|
13
|
+
? ``
|
|
14
|
+
: `
|
|
15
|
+
overflow: auto;
|
|
16
|
+
max-width: calc(100% - (${horizontalMargin} * 2));
|
|
17
|
+
max-height: calc(100% - (${verticalMargin} * 2));
|
|
18
|
+
`}
|
|
19
|
+
`;
|