@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,25 @@
|
|
|
1
|
+
// import theme from "styled-theming";
|
|
2
|
+
import { MATISSE_BLUE, STORM_GREY } from "../../../constants/colors";
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
For now I'm using string values, eventually shared components library will have its own constants file
|
|
6
|
+
for colors/values that should be used here instead
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const color = `${MATISSE_BLUE}`;
|
|
10
|
+
const activeColor = `color: ${STORM_GREY};`;
|
|
11
|
+
const fontSize = "0.875rem";
|
|
12
|
+
const lineHeight = "1.25rem";
|
|
13
|
+
const fontWeight = "400";
|
|
14
|
+
const margin = "0 0.5rem";
|
|
15
|
+
const hover = `text-decoration: none;`;
|
|
16
|
+
|
|
17
|
+
export const fallbackValues = {
|
|
18
|
+
color,
|
|
19
|
+
activeColor,
|
|
20
|
+
fontSize,
|
|
21
|
+
lineHeight,
|
|
22
|
+
fontWeight,
|
|
23
|
+
margin,
|
|
24
|
+
hover
|
|
25
|
+
};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import React, { useContext } from "react";
|
|
2
|
+
import styled, { ThemeContext } from "styled-components";
|
|
3
|
+
import posed from "react-pose";
|
|
4
|
+
import { linear } from "@popmotion/easing";
|
|
5
|
+
import Text from "../text";
|
|
6
|
+
import { Box, Center } from "../layouts";
|
|
7
|
+
import { fallbackValues } from "./ButtonWithAction.theme";
|
|
8
|
+
|
|
9
|
+
import SpinnerIcon from "../../../deprecated/spinner";
|
|
10
|
+
import { noop } from "../../../util/general";
|
|
11
|
+
import { createThemeValues } from "../../../util/themeUtils";
|
|
12
|
+
|
|
13
|
+
const rotate = posed.div({
|
|
14
|
+
fixed: {
|
|
15
|
+
rotate: "0deg"
|
|
16
|
+
},
|
|
17
|
+
rotate: {
|
|
18
|
+
rotate: "360deg",
|
|
19
|
+
transition: {
|
|
20
|
+
rotate: {
|
|
21
|
+
ease: linear,
|
|
22
|
+
duration: 1000,
|
|
23
|
+
loop: Infinity
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const SpinnerContainer = styled.div`
|
|
30
|
+
width: 100%;
|
|
31
|
+
display: flex;
|
|
32
|
+
flex-direction: row;
|
|
33
|
+
align-items: center;
|
|
34
|
+
justify-content: center;
|
|
35
|
+
line-height: 1;
|
|
36
|
+
`;
|
|
37
|
+
|
|
38
|
+
const SpinnerIconWrapper = styled(rotate)`
|
|
39
|
+
width: 24px;
|
|
40
|
+
height: 24px;
|
|
41
|
+
`;
|
|
42
|
+
|
|
43
|
+
const Spinner = () => (
|
|
44
|
+
<SpinnerContainer>
|
|
45
|
+
<SpinnerIconWrapper initialPose="fixed" pose="rotate">
|
|
46
|
+
<SpinnerIcon />
|
|
47
|
+
</SpinnerIconWrapper>
|
|
48
|
+
</SpinnerContainer>
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
/* Most of the time, to use this button you'll only need to specify:
|
|
52
|
+
- A variant (if different than primary)
|
|
53
|
+
- An action
|
|
54
|
+
- Text
|
|
55
|
+
|
|
56
|
+
Optionally, you can also pass:
|
|
57
|
+
- isLoading to show a spinner
|
|
58
|
+
- dataQa for use with test cafe
|
|
59
|
+
- contentOverride to use the button as a wrapper around arbitrary content
|
|
60
|
+
- extraStyles if you need an escape hatch. Extra styles should be used sparingly.
|
|
61
|
+
|
|
62
|
+
Note: the children prop is only used if contentOverride is set to true, in which case
|
|
63
|
+
the text prop is ignored.
|
|
64
|
+
|
|
65
|
+
*/
|
|
66
|
+
|
|
67
|
+
const ButtonWithAction = ({
|
|
68
|
+
action = noop,
|
|
69
|
+
variant = "primary",
|
|
70
|
+
text,
|
|
71
|
+
isLoading = false,
|
|
72
|
+
dataQa = null,
|
|
73
|
+
textExtraStyles,
|
|
74
|
+
contentOverride = false,
|
|
75
|
+
extraStyles = "",
|
|
76
|
+
children
|
|
77
|
+
}) => {
|
|
78
|
+
const themeContext = useContext(ThemeContext);
|
|
79
|
+
const themeValues = createThemeValues(
|
|
80
|
+
themeContext,
|
|
81
|
+
fallbackValues,
|
|
82
|
+
"Button",
|
|
83
|
+
variant
|
|
84
|
+
);
|
|
85
|
+
const loadingExtraStyles = `${extraStyles}; padding-top: 0.75rem; padding-bottom: 0.75rem;`;
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<Box
|
|
89
|
+
variant={variant}
|
|
90
|
+
padding={themeValues.padding}
|
|
91
|
+
minHeight={themeValues.height}
|
|
92
|
+
minWidth={themeValues.minWidth}
|
|
93
|
+
background={themeValues.backgroundColor}
|
|
94
|
+
border={themeValues.border}
|
|
95
|
+
hoverStyles={themeValues.hover}
|
|
96
|
+
focusStyles={themeValues.focus}
|
|
97
|
+
activeStyles={themeValues.active}
|
|
98
|
+
disabledStyles={themeValues.disabled}
|
|
99
|
+
as="button"
|
|
100
|
+
onClick={action}
|
|
101
|
+
borderRadius="2px"
|
|
102
|
+
theme={themeContext}
|
|
103
|
+
extraStyles={isLoading ? loadingExtraStyles : extraStyles}
|
|
104
|
+
dataQa={dataQa}
|
|
105
|
+
>
|
|
106
|
+
{contentOverride ? (
|
|
107
|
+
children
|
|
108
|
+
) : (
|
|
109
|
+
<Center intrinsic>
|
|
110
|
+
{isLoading ? (
|
|
111
|
+
<Spinner />
|
|
112
|
+
) : (
|
|
113
|
+
<Text
|
|
114
|
+
weight={themeValues.fontWeight}
|
|
115
|
+
variant={themeValues.fontSizeVariant}
|
|
116
|
+
color={themeValues.color}
|
|
117
|
+
extraStyles={textExtraStyles}
|
|
118
|
+
>
|
|
119
|
+
{text}
|
|
120
|
+
</Text>
|
|
121
|
+
)}
|
|
122
|
+
</Center>
|
|
123
|
+
)}
|
|
124
|
+
</Box>
|
|
125
|
+
);
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export default ButtonWithAction;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { withKnobs, text } from "@storybook/addon-knobs";
|
|
3
|
+
import ButtonWithAction from "./ButtonWithAction";
|
|
4
|
+
import { Cover, Center } from "../layouts";
|
|
5
|
+
import { ThemeProvider } from "styled-components";
|
|
6
|
+
|
|
7
|
+
const fakeTheme = {
|
|
8
|
+
Button: {
|
|
9
|
+
backgroundColor: {
|
|
10
|
+
primary: `#357FB8`,
|
|
11
|
+
secondary: `transparent`,
|
|
12
|
+
small: `#357FB8`,
|
|
13
|
+
smallSecondary: `transparent`
|
|
14
|
+
},
|
|
15
|
+
color: {
|
|
16
|
+
primary: `#FFFFFF`,
|
|
17
|
+
secondary: `#357FB8`,
|
|
18
|
+
small: `#FFFFFF`,
|
|
19
|
+
smallSecondary: `#357FB8`
|
|
20
|
+
},
|
|
21
|
+
fontWeight: `600`,
|
|
22
|
+
fontSize: `1.125rem`,
|
|
23
|
+
border: {
|
|
24
|
+
primary: `1px solid #357FB8`,
|
|
25
|
+
secondary: `2px solid #357FB8`,
|
|
26
|
+
small: `1px solid #357FB8`,
|
|
27
|
+
smallSecondary: `2px solid #357FB8`
|
|
28
|
+
},
|
|
29
|
+
height: {
|
|
30
|
+
primary: `3rem`,
|
|
31
|
+
secondary: `3rem`,
|
|
32
|
+
small: `2.5rem`,
|
|
33
|
+
smallSecondary: `2.5rem`
|
|
34
|
+
},
|
|
35
|
+
padding: {
|
|
36
|
+
primary: `0.75rem 2rem`,
|
|
37
|
+
secondary: `0.75rem 2rem`,
|
|
38
|
+
small: `0.625rem 1rem`,
|
|
39
|
+
smallSecondary: `0.625rem 1rem`
|
|
40
|
+
},
|
|
41
|
+
focus: `outline: none; box-shadow: 0 0 4px #357FB8`,
|
|
42
|
+
active: {
|
|
43
|
+
primary: `background-color: #182848; border: 1px solid #182848; box-shadow: 0 0 4px #357FB8`,
|
|
44
|
+
secondary: `background-color: #357FB8; color: #FFFFFF; box-shadow: 0 0 4px #357FB8`,
|
|
45
|
+
small: `background-color: #182848; border: 1px solid #182848; box-shadow: 0 0 4px #357FB8`,
|
|
46
|
+
smallSecondary: `background-color: #357FB8; color: #FFFFFF; box-shadow: 0 0 4px #357FB8`
|
|
47
|
+
},
|
|
48
|
+
disabled: {
|
|
49
|
+
primary: `background-color: #6E727E; border: 1px solid #6E727E; &:focus { box-shadow: 0 0 4px #6E727E }`,
|
|
50
|
+
secondary: `color: #6E727E; border: 2px solid #6E727E; &:focus { box-shadow: 0 0 4px #6E727E }`,
|
|
51
|
+
small: `background-color: #6E727E; border: 1px solid #6E727E; &:focus { box-shadow: 0 0 4px #6E727E`,
|
|
52
|
+
smallSecondary: `color: #6E727E; border: 2px solid #6E727E; &:focus { box-shadow: 0 0 4px #6E727E }`
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export default {
|
|
58
|
+
title: "Themed Button",
|
|
59
|
+
component: ButtonWithAction,
|
|
60
|
+
decorators: [
|
|
61
|
+
withKnobs,
|
|
62
|
+
storyFn => (
|
|
63
|
+
<ThemeProvider
|
|
64
|
+
theme={{
|
|
65
|
+
name: text("Theme Name", "default"),
|
|
66
|
+
values: fakeTheme
|
|
67
|
+
}}
|
|
68
|
+
>
|
|
69
|
+
<Cover>
|
|
70
|
+
<div />
|
|
71
|
+
<Center>{storyFn()}</Center>
|
|
72
|
+
<div />
|
|
73
|
+
</Cover>
|
|
74
|
+
</ThemeProvider>
|
|
75
|
+
)
|
|
76
|
+
]
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export const primaryButtonDefault = () => (
|
|
80
|
+
<ButtonWithAction variant="primary" text="Primary Button" />
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
primaryButtonDefault.story = { name: "Default Primary Button" };
|
|
84
|
+
|
|
85
|
+
export const secondaryButtonDefault = () => (
|
|
86
|
+
<ButtonWithAction variant="secondary" text="Secondary Button" />
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
secondaryButtonDefault.story = { name: "Default Secondary Button" };
|
|
90
|
+
|
|
91
|
+
export const smallButtonDefault = () => (
|
|
92
|
+
<ButtonWithAction variant="small" text="Small Button" />
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
smallButtonDefault.story = { name: "Default Small Button" };
|
|
96
|
+
|
|
97
|
+
export const smallSecondaryButtonDefault = () => (
|
|
98
|
+
<ButtonWithAction variant="smallSecondary" text="Small Secondary" />
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
smallSecondaryButtonDefault.story = { name: "Default Small Secondary Button" };
|
|
102
|
+
|
|
103
|
+
export const primaryButtonThemed = () => (
|
|
104
|
+
<ButtonWithAction variant="primary" text="Primary Themed" />
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
primaryButtonThemed.story = { name: "Themed Primary Button" };
|
|
108
|
+
|
|
109
|
+
export const secondaryButtonThemed = () => (
|
|
110
|
+
<ButtonWithAction variant="secondary" text="Themed Secondary" />
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
secondaryButtonThemed.story = { name: "Themed Secondary Button" };
|
|
114
|
+
|
|
115
|
+
export const smallButtonThemed = () => (
|
|
116
|
+
<ButtonWithAction variant="small" text="Themed Small" />
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
smallButtonThemed.story = { name: "Themed Small Button" };
|
|
120
|
+
|
|
121
|
+
export const smallSecondaryButtonThemed = () => (
|
|
122
|
+
<ButtonWithAction variant="smallSecondary" text="Small Secondary" />
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
smallSecondaryButtonThemed.story = { name: "Themed Small Secondary Button" };
|
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
/*
|
|
2
|
+
For now I'm using string values, eventually shared components library will have its own constants file
|
|
3
|
+
for colors/values that should be used here instead
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const padding = {
|
|
7
|
+
primary: "1rem 1.25rem",
|
|
8
|
+
secondary: "1rem 1.25rem",
|
|
9
|
+
back: "1rem 1.25rem",
|
|
10
|
+
smallPrimary: "0.75rem 1rem",
|
|
11
|
+
smallSecondary: "0.75rem 1rem",
|
|
12
|
+
smallGhost: "0",
|
|
13
|
+
ghost: "0.65rem 0",
|
|
14
|
+
danger: "1rem 1.25rem",
|
|
15
|
+
whiteSecondary: "0.75rem 2rem",
|
|
16
|
+
whitePrimary: "1.125rem 0.75rem"
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const color = {
|
|
20
|
+
primary: "#FFFFFF",
|
|
21
|
+
secondary: "#15749D",
|
|
22
|
+
back: "#15749D",
|
|
23
|
+
smallPrimary: "#FFFFFF",
|
|
24
|
+
smallSecondary: "#15749D",
|
|
25
|
+
smallGhost: "#15749D",
|
|
26
|
+
ghost: "#15749D",
|
|
27
|
+
danger: "#FFFFFF",
|
|
28
|
+
whiteSecondary: "#FFFFFF",
|
|
29
|
+
whitePrimary: "#FFFFFF"
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const fontSizeVariant = {
|
|
33
|
+
primary: "pS",
|
|
34
|
+
secondary: "pS",
|
|
35
|
+
back: "pS",
|
|
36
|
+
smallPrimary: "pS",
|
|
37
|
+
smallSecondary: "pS",
|
|
38
|
+
smallGhost: "p",
|
|
39
|
+
ghost: "pL",
|
|
40
|
+
danger: "pS",
|
|
41
|
+
whiteSecondary: "pS",
|
|
42
|
+
whitePrimary: "pS"
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const fontWeight = {
|
|
46
|
+
primary: "600",
|
|
47
|
+
secondary: "600",
|
|
48
|
+
back: "600",
|
|
49
|
+
smallPrimary: "600",
|
|
50
|
+
smallSecondary: "600",
|
|
51
|
+
smallGhost: "400",
|
|
52
|
+
ghost: "600",
|
|
53
|
+
danger: "600",
|
|
54
|
+
whiteSecondary: "600"
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const height = {
|
|
58
|
+
primary: "3rem",
|
|
59
|
+
secondary: "3rem",
|
|
60
|
+
back: "3rem",
|
|
61
|
+
smallPrimary: "2.5rem",
|
|
62
|
+
smallSecondary: "2.5rem",
|
|
63
|
+
smallGhost: "1.5rem",
|
|
64
|
+
ghost: "3rem",
|
|
65
|
+
danger: "3rem",
|
|
66
|
+
whiteSecondary: "3rem",
|
|
67
|
+
whitePrimary: "auto"
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const minWidth = {
|
|
71
|
+
primary: "130px",
|
|
72
|
+
secondary: "130px",
|
|
73
|
+
back: "130px",
|
|
74
|
+
smallPrimary: "100px",
|
|
75
|
+
smallSecondary: "100px",
|
|
76
|
+
smallGhost: "100px",
|
|
77
|
+
ghost: "130px",
|
|
78
|
+
danger: "130px",
|
|
79
|
+
whiteSecondary: "160px",
|
|
80
|
+
whitePrimary: "130px"
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const backgroundColor = {
|
|
84
|
+
primary: "#15749D",
|
|
85
|
+
secondary: "transparent",
|
|
86
|
+
back: "transparent",
|
|
87
|
+
smallPrimary: "#15749D",
|
|
88
|
+
smallSecondary: "transparent",
|
|
89
|
+
smallGhost: "transparent",
|
|
90
|
+
ghost: "transparent",
|
|
91
|
+
danger: "#ED125F",
|
|
92
|
+
whiteSecondary: "transparent",
|
|
93
|
+
whitePrimary: "transparent"
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const border = {
|
|
97
|
+
primary: "2px solid #15749D",
|
|
98
|
+
secondary: "2px solid #15749D",
|
|
99
|
+
back: "2px solid #15749D",
|
|
100
|
+
smallPrimary: "2px solid #15749D",
|
|
101
|
+
smallSecondary: "2px solid #15749D",
|
|
102
|
+
smallGhost: "none",
|
|
103
|
+
ghost: "none",
|
|
104
|
+
danger: "2px solid #ED125F",
|
|
105
|
+
whiteSecondary: "2px solid white",
|
|
106
|
+
whitePrimary: "2px solid transparent"
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const focus = {
|
|
110
|
+
primary: `
|
|
111
|
+
outline: none;
|
|
112
|
+
background-color: #0E506D;
|
|
113
|
+
border: 2px solid #0E506D;
|
|
114
|
+
box-shadow: 0 0 10px #15749D;
|
|
115
|
+
`,
|
|
116
|
+
secondary: `
|
|
117
|
+
outline: none;
|
|
118
|
+
background-color: #DCEAF1;
|
|
119
|
+
box-shadow: 0 0 10px #DCEAF1;
|
|
120
|
+
`,
|
|
121
|
+
back: `
|
|
122
|
+
outline: none;
|
|
123
|
+
background-color: #DCEAF1;
|
|
124
|
+
box-shadow: 0 0 10px #DCEAF1;
|
|
125
|
+
`,
|
|
126
|
+
smallPrimary: `
|
|
127
|
+
outline: none;
|
|
128
|
+
background-color: #0E506D;
|
|
129
|
+
border: 2px solid #0E506D;
|
|
130
|
+
box-shadow: 0 0 10px #15749D;
|
|
131
|
+
`,
|
|
132
|
+
smallSecondary: `
|
|
133
|
+
outline: none;
|
|
134
|
+
background-color: #DCEAF1;
|
|
135
|
+
box-shadow: 0 0 10px #DCEAF1;
|
|
136
|
+
`,
|
|
137
|
+
smallGhost: `
|
|
138
|
+
outline: none;
|
|
139
|
+
box-shadow: none;
|
|
140
|
+
color: #0E506D;
|
|
141
|
+
`,
|
|
142
|
+
ghost: `
|
|
143
|
+
outline: none;
|
|
144
|
+
box-shadow: none;
|
|
145
|
+
color: #0E506D;
|
|
146
|
+
`,
|
|
147
|
+
danger: `
|
|
148
|
+
outline: none;
|
|
149
|
+
background-color: #BA002C;
|
|
150
|
+
border: 2px solid #BA002C;
|
|
151
|
+
box-shadow: 0 0 10px #ED125F;
|
|
152
|
+
`,
|
|
153
|
+
whiteSecondary: `
|
|
154
|
+
outline: none;
|
|
155
|
+
background-color: #ffffff4D;
|
|
156
|
+
> div > span {
|
|
157
|
+
background-color: transparent;
|
|
158
|
+
}
|
|
159
|
+
`,
|
|
160
|
+
whitePrimary: `
|
|
161
|
+
outline: none;
|
|
162
|
+
background-color: #ffffff4D;
|
|
163
|
+
border: 2px solid transparent;
|
|
164
|
+
> div > span {
|
|
165
|
+
background-color: transparent;
|
|
166
|
+
}
|
|
167
|
+
`
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
const hover = {
|
|
171
|
+
primary: `
|
|
172
|
+
cursor: pointer;
|
|
173
|
+
background-color: #116285;
|
|
174
|
+
border: 2px solid #116285;
|
|
175
|
+
box-shadow: 0 0 10px #15749D;
|
|
176
|
+
`,
|
|
177
|
+
secondary: `
|
|
178
|
+
cursor: pointer;
|
|
179
|
+
background-color: #DCEAF1;
|
|
180
|
+
box-shadow: 0 0 10px #DCEAF1;
|
|
181
|
+
`,
|
|
182
|
+
back: `
|
|
183
|
+
cursor: pointer;
|
|
184
|
+
background-color: #DCEAF1;
|
|
185
|
+
box-shadow: 0 0 10px #DCEAF1;
|
|
186
|
+
`,
|
|
187
|
+
smallPrimary: `
|
|
188
|
+
cursor: pointer;
|
|
189
|
+
background-color: #116285;
|
|
190
|
+
border: 2px solid #116285;
|
|
191
|
+
box-shadow: 0 0 10px #15749D;
|
|
192
|
+
`,
|
|
193
|
+
smallSecondary: `
|
|
194
|
+
cursor: pointer;
|
|
195
|
+
background-color: #DCEAF1;
|
|
196
|
+
box-shadow: 0 0 10px #DCEAF1;
|
|
197
|
+
`,
|
|
198
|
+
smallGhost: `
|
|
199
|
+
cursor: pointer;
|
|
200
|
+
color: #0E506D;
|
|
201
|
+
`,
|
|
202
|
+
ghost: `
|
|
203
|
+
cursor: pointer;
|
|
204
|
+
color: #0E506D;
|
|
205
|
+
`,
|
|
206
|
+
danger: `
|
|
207
|
+
outline: none;
|
|
208
|
+
background-color: #BA002C;
|
|
209
|
+
border: 2px solid #BA002C;
|
|
210
|
+
box-shadow: 0 0 10px #ED125F;
|
|
211
|
+
`,
|
|
212
|
+
whiteSecondary: `
|
|
213
|
+
outline: none;
|
|
214
|
+
background-color: #ffffff4D;
|
|
215
|
+
> div > span {
|
|
216
|
+
background-color: transparent;
|
|
217
|
+
}
|
|
218
|
+
`,
|
|
219
|
+
whitePrimary: `
|
|
220
|
+
outline: none;
|
|
221
|
+
background-color: #ffffff4D;
|
|
222
|
+
border: 2px solid transparent;
|
|
223
|
+
> div > span {
|
|
224
|
+
background-color: transparent;
|
|
225
|
+
}
|
|
226
|
+
`
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
const active = {
|
|
230
|
+
primary: `
|
|
231
|
+
background-color: #0E506D;
|
|
232
|
+
border: 2px solid #0E506D;
|
|
233
|
+
box-shadow: 0 0 10px #15749D;
|
|
234
|
+
`,
|
|
235
|
+
secondary: `
|
|
236
|
+
background-color: #B8D5E1;
|
|
237
|
+
box-shadow: 0 0 10px #B8D5E1;
|
|
238
|
+
`,
|
|
239
|
+
back: `
|
|
240
|
+
background-color: #B8D5E1;
|
|
241
|
+
box-shadow: 0 0 10px #B8D5E1;
|
|
242
|
+
`,
|
|
243
|
+
smallPrimary: `
|
|
244
|
+
background-color: #0E506D;
|
|
245
|
+
border: 2px solid #0E506D;
|
|
246
|
+
box-shadow: 0 0 10px #15749D;
|
|
247
|
+
`,
|
|
248
|
+
smallSecondary: `
|
|
249
|
+
background-color: #B8D5E1;
|
|
250
|
+
box-shadow: 0 0 10px #B8D5E1;
|
|
251
|
+
`,
|
|
252
|
+
smallGhost: `
|
|
253
|
+
background-color: transparent;
|
|
254
|
+
color: #15749D;
|
|
255
|
+
box-shadow: none;
|
|
256
|
+
`,
|
|
257
|
+
ghost: `
|
|
258
|
+
background-color: transparent;
|
|
259
|
+
color: #15749D;
|
|
260
|
+
box-shadow: none;
|
|
261
|
+
`,
|
|
262
|
+
danger: `
|
|
263
|
+
outline: none;
|
|
264
|
+
background-color: #870000;
|
|
265
|
+
border: 2px solid #870000;
|
|
266
|
+
box-shadow: 0 0 10px #ED125F;
|
|
267
|
+
`,
|
|
268
|
+
whiteSecondary: `
|
|
269
|
+
outline: none;
|
|
270
|
+
background-color: #00000033;
|
|
271
|
+
box-shadow: 0 0 10px #00000033;
|
|
272
|
+
> div > span {
|
|
273
|
+
background-color: transparent;
|
|
274
|
+
}
|
|
275
|
+
`,
|
|
276
|
+
whitePrimary: `
|
|
277
|
+
outline: none;
|
|
278
|
+
background-color: #00000033;
|
|
279
|
+
box-shadow: 0 0 10px #00000033;
|
|
280
|
+
border: 2px solid transparent;
|
|
281
|
+
> div > span {
|
|
282
|
+
background-color: transparent;
|
|
283
|
+
}
|
|
284
|
+
`
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
const disabled = {
|
|
288
|
+
primary: `
|
|
289
|
+
background-color: #6E727E;
|
|
290
|
+
border: 2px solid #6E727E;
|
|
291
|
+
&:focus {
|
|
292
|
+
box-shadow: 0 0 10px #6E727E;
|
|
293
|
+
}
|
|
294
|
+
`,
|
|
295
|
+
secondary: `
|
|
296
|
+
color: #6E727E;
|
|
297
|
+
border: 2px solid #6E727E;
|
|
298
|
+
&:focus {
|
|
299
|
+
box-shadow: 0 0 10px #6E727E;
|
|
300
|
+
}
|
|
301
|
+
`,
|
|
302
|
+
back: `
|
|
303
|
+
color: #6E727E;
|
|
304
|
+
border: 2px solid #6E727E;
|
|
305
|
+
&:focus {
|
|
306
|
+
box-shadow: 0 0 10px #6E727E;
|
|
307
|
+
}
|
|
308
|
+
`,
|
|
309
|
+
smallPrimary: `
|
|
310
|
+
background-color: #6E727E;
|
|
311
|
+
border: 2px solid #6E727E;
|
|
312
|
+
&:focus {
|
|
313
|
+
box-shadow: 0 0 10px #6E727E;
|
|
314
|
+
}
|
|
315
|
+
`,
|
|
316
|
+
smallSecondary: `
|
|
317
|
+
color: #6E727E;
|
|
318
|
+
border: 2px solid #6E727E;
|
|
319
|
+
&:focus {
|
|
320
|
+
box-shadow: 0 0 10px #6E727E;
|
|
321
|
+
}
|
|
322
|
+
`,
|
|
323
|
+
smallGhost: `
|
|
324
|
+
color: #6E727E;
|
|
325
|
+
border: none;
|
|
326
|
+
`,
|
|
327
|
+
ghost: `
|
|
328
|
+
color: #6E727E;
|
|
329
|
+
border: none;
|
|
330
|
+
`,
|
|
331
|
+
whiteSecondary: `
|
|
332
|
+
color: #6E727E;
|
|
333
|
+
border: 2px solid #6E727E;
|
|
334
|
+
&:focus {
|
|
335
|
+
box-shadow: 0 0 10px #6E727E;
|
|
336
|
+
}
|
|
337
|
+
`,
|
|
338
|
+
whitePrimary: `
|
|
339
|
+
color: #6E727E;
|
|
340
|
+
border: 2px solid #6E727E;
|
|
341
|
+
&:focus {
|
|
342
|
+
box-shadow: 0 0 10px #6E727E;
|
|
343
|
+
}
|
|
344
|
+
`
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
export const fallbackValues = {
|
|
348
|
+
padding,
|
|
349
|
+
color,
|
|
350
|
+
fontSizeVariant,
|
|
351
|
+
fontWeight,
|
|
352
|
+
height,
|
|
353
|
+
minWidth,
|
|
354
|
+
backgroundColor,
|
|
355
|
+
border,
|
|
356
|
+
hover,
|
|
357
|
+
focus,
|
|
358
|
+
active,
|
|
359
|
+
disabled
|
|
360
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import * as R from "ramda";
|
|
3
|
+
import { URL_TEST } from "../../../constants/regex_constants";
|
|
4
|
+
import { InternalLink, ExternalLink } from "../link";
|
|
5
|
+
import { safeChildren } from "../../../util/general";
|
|
6
|
+
import ButtonWithAction from "../button-with-action";
|
|
7
|
+
|
|
8
|
+
const ButtonWithLink = ({
|
|
9
|
+
url = "/",
|
|
10
|
+
disabled = false,
|
|
11
|
+
extraStyles,
|
|
12
|
+
...otherProps
|
|
13
|
+
}) => {
|
|
14
|
+
const ButtonWithLinkWrapper = ({ children, url, disabled, extraStyles }) => {
|
|
15
|
+
if (disabled) {
|
|
16
|
+
return safeChildren(children, <span />);
|
|
17
|
+
}
|
|
18
|
+
return R.test(URL_TEST, url) ? (
|
|
19
|
+
<ExternalLink href={url} tabIndex="-1" extraStyles={extraStyles}>
|
|
20
|
+
{safeChildren(children, <span />)}
|
|
21
|
+
</ExternalLink>
|
|
22
|
+
) : (
|
|
23
|
+
<InternalLink to={url} tabIndex="-1" extraStyles={extraStyles}>
|
|
24
|
+
{safeChildren(children, <span />)}
|
|
25
|
+
</InternalLink>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<ButtonWithLinkWrapper
|
|
31
|
+
url={url}
|
|
32
|
+
disabled={disabled}
|
|
33
|
+
extraStyles={extraStyles}
|
|
34
|
+
>
|
|
35
|
+
<ButtonWithAction {...otherProps} extraStyles={extraStyles} />
|
|
36
|
+
</ButtonWithLinkWrapper>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export default ButtonWithLink;
|