@thecb/components 10.2.0 → 10.2.1-beta.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "10.2.0",
3
+ "version": "10.2.1-beta.0",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -34,14 +34,15 @@ const Breadcrumbs = ({ breadcrumbsList = [] }) => {
34
34
  extraStyles={`
35
35
  text-transform: uppercase;
36
36
  ${isActive.toString() === "true" &&
37
- `pointer-events: none;
38
- color: ${themeValues.activeBreadcrumbColor};
37
+ `color: ${themeValues.activeBreadcrumbColor};
38
+ pointer-events: none;
39
+ text-decoration: none;
39
40
  `}
40
41
  &:first-child {
41
42
  margin-left: 0;
42
43
  }
43
44
  &:active {
44
- color: ${themeValues.activeColor};
45
+ color: ${themeValues.activeColor};
45
46
  }`}
46
47
  >
47
48
  {linkText}
@@ -1,5 +1,8 @@
1
1
  // import theme from "styled-theming";
2
- import { MATISSE_BLUE, STORM_GREY } from "../../../constants/colors";
2
+ import { colors, styleConstants } from "../../../constants";
3
+
4
+ const { MATISSE_BLUE, STORM_GREY } = colors;
5
+ const { LINK_TEXT_DECORATION } = styleConstants;
3
6
 
4
7
  /*
5
8
  For now I'm using string values, eventually shared components library will have its own constants file
@@ -13,7 +16,7 @@ const fontSize = "0.875rem";
13
16
  const lineHeight = "1.25rem";
14
17
  const fontWeight = "400";
15
18
  const margin = "0.5rem";
16
- const hover = `text-decoration: none;`;
19
+ const hover = `text-decoration: ${LINK_TEXT_DECORATION};`;
17
20
 
18
21
  export const fallbackValues = {
19
22
  color,
@@ -57,7 +57,7 @@ const Spinner = ({ color, isMobile }) => (
57
57
 
58
58
  Note: the children prop is only used if contentOverride is set to true, in which case
59
59
  the text prop is ignored.
60
-
60
+
61
61
  */
62
62
 
63
63
  const ButtonWithAction = forwardRef(
@@ -95,9 +95,6 @@ const ButtonWithAction = forwardRef(
95
95
  background-color: ${themeValues.hoverBackgroundColor};
96
96
  border-color: ${themeValues.hoverBorderColor};
97
97
  color: ${themeValues.hoverColor};
98
- text-decoration: ${
99
- variant === "ghost" || variant === "smallGhost" ? "underline" : "none"
100
- };
101
98
  cursor: pointer;
102
99
  `;
103
100
  const activeStyles = `
@@ -105,9 +102,6 @@ const ButtonWithAction = forwardRef(
105
102
  background-color: ${themeValues.activeBackgroundColor};
106
103
  border-color: ${themeValues.activeBorderColor};
107
104
  color: ${themeValues.activeColor};
108
- text-decoration: ${
109
- variant === "ghost" || variant === "smallGhost" ? "underline" : "none"
110
- };
111
105
  `;
112
106
  const disabledStyles = `
113
107
  background-color: #6D717E;
@@ -154,6 +148,7 @@ const ButtonWithAction = forwardRef(
154
148
  weight={themeValues.fontWeight}
155
149
  variant={themeValues.fontSizeVariant}
156
150
  color={themeValues.color}
151
+ textDecoration={themeValues.textDecoration}
157
152
  textWrap={textWrap}
158
153
  extraStyles={textExtraStyles}
159
154
  >
@@ -1,4 +1,6 @@
1
- import {
1
+ import { colors, styleConstants } from "../../../constants";
2
+
3
+ const {
2
4
  WHITE,
3
5
  TRANSPARENT,
4
6
  SAPPHIRE_BLUE,
@@ -6,7 +8,9 @@ import {
6
8
  MATISSE_BLUE,
7
9
  RASPBERRY,
8
10
  ERROR_COLOR
9
- } from "../../../constants/colors";
11
+ } = colors;
12
+
13
+ const { LINK_TEXT_DECORATION } = styleConstants;
10
14
 
11
15
  const padding = {
12
16
  primary: "0.75rem 1.5rem",
@@ -98,6 +102,21 @@ const minWidth = {
98
102
  whitePrimary: "130px"
99
103
  };
100
104
 
105
+ const textDecoration = {
106
+ primary: "none",
107
+ secondary: "none",
108
+ back: "none",
109
+ smallPrimary: "none",
110
+ smallSecondary: "none",
111
+ smallGhost: LINK_TEXT_DECORATION,
112
+ ghost: LINK_TEXT_DECORATION,
113
+ tertiary: "none",
114
+ danger: "none",
115
+ dangerSecondary: "none",
116
+ whiteSecondary: "none",
117
+ whitePrimary: "none"
118
+ };
119
+
101
120
  const backgroundColor = {
102
121
  primary: MATISSE_BLUE,
103
122
  secondary: TRANSPARENT,
@@ -225,6 +244,7 @@ export const fallbackValues = {
225
244
  fontWeight,
226
245
  height,
227
246
  minWidth,
247
+ textDecoration,
228
248
  backgroundColor,
229
249
  border,
230
250
  hoverBackgroundColor,
@@ -9,8 +9,8 @@ const ButtonWithLink = ({
9
9
  url = "/",
10
10
  disabled = false,
11
11
  fileLink = false,
12
- extraStyles,
13
- linkExtraStyles,
12
+ extraStyles = "",
13
+ linkExtraStyles = "",
14
14
  newTab = false,
15
15
  dataQa,
16
16
  ...otherProps
@@ -1,6 +1,10 @@
1
1
  import React, { forwardRef } from "react";
2
2
  import styled from "styled-components";
3
- import { ROYAL_BLUE } from "../../../constants/colors";
3
+ import { colors, styleConstants } from "../../../constants";
4
+
5
+ const { ROYAL_BLUE } = colors;
6
+ const { LINK_TEXT_DECORATION } = styleConstants;
7
+
4
8
  /*
5
9
  The extracting of props and the disabling of the eslint rule is to stop React from complaining about
6
10
  unrecognized DOM attributes.
@@ -18,10 +22,10 @@ export const StyledExternalLink = styled(
18
22
  font-weight: ${({ weight }) => weight};
19
23
  font-family: ${({ fontFamily }) => fontFamily};
20
24
  line-height: ${({ lineheight }) => lineheight};
25
+ text-decoration: ${LINK_TEXT_DECORATION};
21
26
 
22
27
  &:hover {
23
28
  color: ${({ hoverColor }) => hoverColor};
24
- text-decoration: underline;
25
29
  }
26
30
 
27
31
  &:focus {
@@ -30,7 +34,6 @@ export const StyledExternalLink = styled(
30
34
  }
31
35
 
32
36
  &:active {
33
- text-decoration: underline;
34
37
  color: ${({ activeColor }) => activeColor};
35
38
  }
36
39
 
@@ -1,7 +1,11 @@
1
1
  import React, { forwardRef } from "react";
2
2
  import styled from "styled-components";
3
3
  import { Link } from "react-router-dom";
4
- import { ROYAL_BLUE } from "../../../constants/colors";
4
+ import { colors, styleConstants } from "../../../constants";
5
+
6
+ const { ROYAL_BLUE } = colors;
7
+ const { LINK_TEXT_DECORATION } = styleConstants;
8
+
5
9
  /*
6
10
  The extracting of props and the disabling of the eslint rule is to stop React from complaining about
7
11
  unrecognized DOM attributes.
@@ -24,10 +28,10 @@ export const StyledInternalLink = styled(
24
28
  font-size: ${({ fontSize }) => fontSize};
25
29
  font-family: ${({ fontFamily }) => fontFamily};
26
30
  margin: ${({ margin }) => margin};
31
+ text-decoration: ${LINK_TEXT_DECORATION};
27
32
 
28
33
  &:hover {
29
34
  color: ${({ hoverColor }) => hoverColor};
30
- text-decoration: underline;
31
35
  }
32
36
 
33
37
  &:focus {
@@ -36,7 +40,6 @@ export const StyledInternalLink = styled(
36
40
  }
37
41
 
38
42
  &:active {
39
- text-decoration: underline;
40
43
  color: ${({ activeColor }) => activeColor};
41
44
  }
42
45
 
@@ -10,6 +10,7 @@ const Text = ({
10
10
  themeValues,
11
11
  weight = FONT_WEIGHT_REGULAR,
12
12
  color = FIREFLY_GREY,
13
+ textDecoration = "none",
13
14
  textWrap = true,
14
15
  extraStyles = ``,
15
16
  hoverStyles,
@@ -26,6 +27,7 @@ const Text = ({
26
27
  weight={weight}
27
28
  color={color}
28
29
  fontFamily={themeValues.fontFamily}
30
+ textDecoration={textDecoration}
29
31
  as={as}
30
32
  extraStyles={extraStyles}
31
33
  hoverStyles={hoverStyles}
@@ -8,6 +8,7 @@ export const TextSpan = styled.span`
8
8
  font-weight: ${({ weight }) => weight};
9
9
  font-family: ${({ fontFamily }) => fontFamily};
10
10
  color: ${({ color }) => color};
11
+ text-decoration: ${textDecoration => textDecoration};
11
12
  white-space: ${({ $textWrap }) => ($textWrap ? "initial" : "nowrap")};
12
13
 
13
14
  &:hover {
@@ -94,6 +94,7 @@ export const getPagesPanel = (page, pagesCount) => {
94
94
 
95
95
  const Pagination = ({
96
96
  activeBorderWidth = "3px",
97
+ ariaLabel,
97
98
  arrowColor,
98
99
  borderRadius = "3px",
99
100
  buttonHeight = "44px",
@@ -107,7 +108,6 @@ const Pagination = ({
107
108
  pageNext,
108
109
  pagePrevious,
109
110
  setCurrentPage,
110
- ariaLabel,
111
111
  themeValues
112
112
  }) => {
113
113
  const { isMobile } = useContext(ThemeContext);
@@ -115,12 +115,6 @@ const Pagination = ({
115
115
  const extraStyles = `
116
116
  min-width: ${buttonWidth}; min-height: 100%; padding: 0;
117
117
  border-radius: ${borderRadius};
118
- &:hover, &:focus {
119
- text-decoration: none;
120
- > * > span {
121
- text-decoration: none;
122
- }
123
- }
124
118
  > * > span {
125
119
  color: ${numberColor ?? themeValues.numberColor}
126
120
  }
@@ -0,0 +1,32 @@
1
+ import React from "react";
2
+ import { number, text } from "@storybook/addon-knobs";
3
+ import Pagination from "./Pagination";
4
+ import page from "../../../../.storybook/page";
5
+
6
+ export const pagination = () => (
7
+ <Pagination
8
+ activeBorderWidth={text("activeBorderWidth", "3px", "props")}
9
+ ariaLabel={text("ariaLabel", "Aria Label", "props")}
10
+ arrowColor={text("arrowColor", "#FFFFFF", "props")}
11
+ borderRadius={text("borderRadius", "3px", "props")}
12
+ buttonHeight={text("buttonHeight", "44px", "props")}
13
+ buttonWidth={text("buttonWidth", "44px", "props")}
14
+ childGap={text("childGap", "24px", "props")}
15
+ currentPage={number("currentPage", 2)}
16
+ fontSize={text("fontSize", "17px", "props")}
17
+ fontWeight={text("fontWeight", "900", "props")}
18
+ numberColor={text("numberColor", "#15749D", "props")}
19
+ pageCount={number("pageCount", 3)}
20
+ pageNext={() => {}}
21
+ pagePrevious={() => {}}
22
+ setCurrentPage={() => {}}
23
+ // themeValues
24
+ />
25
+ );
26
+
27
+ const story = page({
28
+ title: "Components|Molecules/Pagination",
29
+ Component: Pagination
30
+ });
31
+
32
+ export default story;
@@ -1,8 +1,7 @@
1
1
  import {
2
2
  WHITE,
3
3
  MATISSE_BLUE,
4
- ALABASTER_WHITE,
5
- STORM_GREY
4
+ ALABASTER_WHITE
6
5
  } from "../../../constants/colors";
7
6
 
8
7
  const arrowColor = WHITE;
@@ -36,7 +36,6 @@ const TabSidebar = ({ links, isMobile, themeValues }) => (
36
36
  to={route}
37
37
  key={`${route}-${index}`}
38
38
  extraStyles={`&:hover {
39
- text-decoration: none;
40
39
  ${
41
40
  active
42
41
  ? `> * {
@@ -1,3 +1,4 @@
1
1
  import * as colors from "./colors";
2
+ import * as styleConstants from "./style_constants";
2
3
 
3
- export { colors };
4
+ export { colors, styleConstants };
@@ -1,4 +1,13 @@
1
- import * as colors from "./colors";
2
- import * as fontWeights from "./style_constants";
1
+ export * as colors from "./colors";
2
+ export * as general from "./general";
3
+ export * as regexConstants from "./regex_constants";
4
+ export * as styleConstants from "./style_constants";
3
5
 
4
- export { colors, fontWeights };
6
+ /**
7
+ * This export is named "fontWeights" and referenced as such in much existing code.
8
+ * Navigate Frontend is one example that uses this particular export. However, new
9
+ * usage of style constants should reference the `styleConstants` export instead.
10
+ *
11
+ * @deprecated
12
+ */
13
+ export * as fontWeights from "./style_constants";
@@ -0,0 +1,11 @@
1
+ type StyleDeclaration = string;
2
+
3
+ export const HEADER_HEIGHT: StyleDeclaration;
4
+ export const FOOTER_HEIGHT: StyleDeclaration;
5
+ export const SPACER_HEIGHT: StyleDeclaration;
6
+ export const JUMBO_HEIGHT: StyleDeclaration;
7
+ export const COMPACT_JUMBO_HEIGHT: StyleDeclaration;
8
+ export const FONT_WEIGHT_REGULAR: StyleDeclaration;
9
+ export const FONT_WEIGHT_BOLD: StyleDeclaration;
10
+ export const FONT_WEIGHT_SEMIBOLD: StyleDeclaration;
11
+ export const LINK_TEXT_DECORATION: StyleDeclaration;
@@ -8,6 +8,7 @@ const COMPACT_JUMBO_HEIGHT = "65px";
8
8
  const FONT_WEIGHT_REGULAR = "400";
9
9
  const FONT_WEIGHT_BOLD = "700";
10
10
  const FONT_WEIGHT_SEMIBOLD = "600";
11
+ const LINK_TEXT_DECORATION = "underline solid 1px";
11
12
 
12
13
  export {
13
14
  HEADER_HEIGHT,
@@ -17,5 +18,6 @@ export {
17
18
  COMPACT_JUMBO_HEIGHT,
18
19
  FONT_WEIGHT_REGULAR,
19
20
  FONT_WEIGHT_BOLD,
20
- FONT_WEIGHT_SEMIBOLD
21
+ FONT_WEIGHT_SEMIBOLD,
22
+ LINK_TEXT_DECORATION
21
23
  };