@ndla/ui 44.0.12 → 44.0.14

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.
Files changed (73) hide show
  1. package/es/ContactBlock/ContactBlock.js +13 -13
  2. package/es/LinkBlock/LinkBlock.js +6 -6
  3. package/es/Masthead/Masthead.js +13 -34
  4. package/es/Masthead/MastheadSearchModal.js +2 -4
  5. package/es/Masthead/index.js +2 -2
  6. package/es/ProgrammeCard/ProgrammeCard.js +3 -5
  7. package/es/Search/ToggleSearchButton.js +9 -24
  8. package/es/Table/Table.js +36 -30
  9. package/es/Table/index.js +1 -0
  10. package/es/TreeStructure/FolderItem.js +11 -9
  11. package/es/User/UserInfo.js +6 -3
  12. package/es/User/parseUserObject.js +1 -1
  13. package/es/all.css +1 -1
  14. package/es/index.js +2 -2
  15. package/es/locale/messages-en.js +0 -2
  16. package/es/locale/messages-nb.js +0 -2
  17. package/es/locale/messages-nn.js +0 -2
  18. package/es/locale/messages-se.js +0 -2
  19. package/es/locale/messages-sma.js +0 -2
  20. package/lib/ContactBlock/ContactBlock.js +13 -13
  21. package/lib/LinkBlock/LinkBlock.js +6 -6
  22. package/lib/Masthead/Masthead.d.ts +0 -6
  23. package/lib/Masthead/Masthead.js +14 -36
  24. package/lib/Masthead/MastheadSearchModal.d.ts +1 -2
  25. package/lib/Masthead/MastheadSearchModal.js +2 -4
  26. package/lib/Masthead/index.d.ts +2 -2
  27. package/lib/Masthead/index.js +1 -10
  28. package/lib/ProgrammeCard/ProgrammeCard.js +3 -5
  29. package/lib/Search/ToggleSearchButton.d.ts +0 -2
  30. package/lib/Search/ToggleSearchButton.js +8 -23
  31. package/lib/Table/Table.d.ts +1 -0
  32. package/lib/Table/Table.js +43 -36
  33. package/lib/Table/index.d.ts +1 -0
  34. package/lib/Table/index.js +10 -2
  35. package/lib/TreeStructure/FolderItem.js +11 -9
  36. package/lib/User/UserInfo.js +6 -3
  37. package/lib/User/parseUserObject.d.ts +1 -1
  38. package/lib/User/parseUserObject.js +1 -1
  39. package/lib/all.css +1 -1
  40. package/lib/index.d.ts +2 -2
  41. package/lib/index.js +7 -7
  42. package/lib/locale/messages-en.d.ts +0 -2
  43. package/lib/locale/messages-en.js +0 -2
  44. package/lib/locale/messages-nb.d.ts +0 -2
  45. package/lib/locale/messages-nb.js +0 -2
  46. package/lib/locale/messages-nn.d.ts +0 -2
  47. package/lib/locale/messages-nn.js +0 -2
  48. package/lib/locale/messages-se.d.ts +0 -2
  49. package/lib/locale/messages-se.js +0 -2
  50. package/lib/locale/messages-sma.d.ts +0 -2
  51. package/lib/locale/messages-sma.js +0 -2
  52. package/package.json +16 -16
  53. package/src/ContactBlock/ContactBlock.tsx +1 -0
  54. package/src/LinkBlock/LinkBlock.tsx +1 -0
  55. package/src/Masthead/Masthead.tsx +6 -38
  56. package/src/Masthead/MastheadSearchModal.tsx +2 -3
  57. package/src/Masthead/index.ts +2 -2
  58. package/src/ProgrammeCard/ProgrammeCard.tsx +2 -2
  59. package/src/Search/ToggleSearchButton.tsx +21 -38
  60. package/src/Table/Table.tsx +166 -19
  61. package/src/Table/index.ts +1 -0
  62. package/src/TreeStructure/FolderItem.tsx +38 -37
  63. package/src/User/UserInfo.tsx +3 -1
  64. package/src/User/__tests__/parseUserObject-test.ts +1 -1
  65. package/src/User/parseUserObject.ts +1 -1
  66. package/src/index.ts +2 -2
  67. package/src/locale/messages-en.ts +0 -2
  68. package/src/locale/messages-nb.ts +0 -2
  69. package/src/locale/messages-nn.ts +0 -2
  70. package/src/locale/messages-se.ts +0 -2
  71. package/src/locale/messages-sma.ts +0 -2
  72. package/src/main.scss +0 -1
  73. package/src/Table/component.tables.scss +0 -223
package/lib/index.d.ts CHANGED
@@ -8,11 +8,11 @@
8
8
  export { default as SectionHeading } from './SectionHeading';
9
9
  export { ConceptNotionV2, ImageEmbed, AudioEmbed, H5pEmbed, ExternalEmbed, IframeEmbed, FootnoteEmbed, BrightcoveEmbed, ContentLinkEmbed, RelatedContentEmbed, ConceptEmbed, ConceptListEmbed, UnknownEmbed, } from './Embed';
10
10
  export { ArticleByline, ArticleFootNotes, ArticleIntroduction, ArticleTitle, ArticleWrapper, ArticleHeaderWrapper, default as Article, } from './Article';
11
- export { default as Table } from './Table';
11
+ export { default as Table, TableStyling } from './Table';
12
12
  export { default as ResourcesWrapper, ResourcesTopicTitle } from './ResourcesWrapper';
13
13
  export { createUniversalPortal } from './utils/createUniversalPortal';
14
14
  export { default as NoContentBox } from './NoContentBox';
15
- export { default as Masthead, MastheadItem, getMastheadHeight, useMastheadHeight, SkipToMainContent } from './Masthead';
15
+ export { default as Masthead, getMastheadHeight, useMastheadHeight, SkipToMainContent } from './Masthead';
16
16
  export { default as ContentLoader } from './ContentLoader';
17
17
  export { default as RelatedArticleList, RelatedArticle, RelatedArticleListV2 } from './RelatedArticleList';
18
18
  export { ErrorResourceAccessDenied, default as ErrorMessage } from './ErrorMessage';
package/lib/index.js CHANGED
@@ -706,12 +706,6 @@ Object.defineProperty(exports, "Masthead", {
706
706
  return _Masthead.default;
707
707
  }
708
708
  });
709
- Object.defineProperty(exports, "MastheadItem", {
710
- enumerable: true,
711
- get: function get() {
712
- return _Masthead.MastheadItem;
713
- }
714
- });
715
709
  Object.defineProperty(exports, "MastheadSearchModal", {
716
710
  enumerable: true,
717
711
  get: function get() {
@@ -1102,6 +1096,12 @@ Object.defineProperty(exports, "Table", {
1102
1096
  return _Table.default;
1103
1097
  }
1104
1098
  });
1099
+ Object.defineProperty(exports, "TableStyling", {
1100
+ enumerable: true,
1101
+ get: function get() {
1102
+ return _Table.TableStyling;
1103
+ }
1104
+ });
1105
1105
  Object.defineProperty(exports, "TagSelector", {
1106
1106
  enumerable: true,
1107
1107
  get: function get() {
@@ -1279,7 +1279,7 @@ Object.defineProperty(exports, "useSnack", {
1279
1279
  var _SectionHeading = _interopRequireDefault(require("./SectionHeading"));
1280
1280
  var _Embed = require("./Embed");
1281
1281
  var _Article = _interopRequireWildcard(require("./Article"));
1282
- var _Table = _interopRequireDefault(require("./Table"));
1282
+ var _Table = _interopRequireWildcard(require("./Table"));
1283
1283
  var _ResourcesWrapper = _interopRequireWildcard(require("./ResourcesWrapper"));
1284
1284
  var _createUniversalPortal = require("./utils/createUniversalPortal");
1285
1285
  var _NoContentBox = _interopRequireDefault(require("./NoContentBox"));
@@ -29,8 +29,6 @@ declare const messages: {
29
29
  loggedInAsButton: string;
30
30
  role: {
31
31
  employee: string;
32
- faculty: string;
33
- staff: string;
34
32
  student: string;
35
33
  };
36
34
  buttonLogIn: string;
@@ -1032,8 +1032,6 @@ var messages = _objectSpread(_objectSpread({
1032
1032
  loggedInAsButton: 'You are logged in as {{role}}',
1033
1033
  role: {
1034
1034
  employee: 'Employee',
1035
- faculty: 'Employee',
1036
- staff: 'Employee',
1037
1035
  student: 'Student'
1038
1036
  },
1039
1037
  buttonLogIn: 'Log in with Feide',
@@ -29,8 +29,6 @@ declare const messages: {
29
29
  loggedInAsButton: string;
30
30
  role: {
31
31
  employee: string;
32
- faculty: string;
33
- staff: string;
34
32
  student: string;
35
33
  };
36
34
  buttonLogIn: string;
@@ -1030,8 +1030,6 @@ var messages = _objectSpread(_objectSpread({
1030
1030
  loggedInAsButton: 'Du er pålogget som {{role}}',
1031
1031
  role: {
1032
1032
  employee: 'ansatt',
1033
- faculty: 'ansatt',
1034
- staff: 'ansatt',
1035
1033
  student: 'elev'
1036
1034
  },
1037
1035
  buttonLogIn: 'Logg inn med Feide',
@@ -29,8 +29,6 @@ declare const messages: {
29
29
  loggedInAsButton: string;
30
30
  role: {
31
31
  employee: string;
32
- faculty: string;
33
- staff: string;
34
32
  student: string;
35
33
  };
36
34
  buttonLogIn: string;
@@ -1030,8 +1030,6 @@ var messages = _objectSpread(_objectSpread({
1030
1030
  loggedInAsButton: 'Du er pålogga som {{role}}',
1031
1031
  role: {
1032
1032
  employee: 'tilsett',
1033
- faculty: 'tilsett',
1034
- staff: 'tilsett',
1035
1033
  student: 'elev'
1036
1034
  },
1037
1035
  buttonLogIn: 'Logg inn med Feide',
@@ -29,8 +29,6 @@ declare const messages: {
29
29
  loggedInAsButton: string;
30
30
  role: {
31
31
  employee: string;
32
- faculty: string;
33
- staff: string;
34
32
  student: string;
35
33
  };
36
34
  buttonLogIn: string;
@@ -1030,8 +1030,6 @@ var messages = _objectSpread(_objectSpread({
1030
1030
  loggedInAsButton: 'Don leat sisaloggejuvvon {{role}}',
1031
1031
  role: {
1032
1032
  employee: 'bargi',
1033
- faculty: 'bargi',
1034
- staff: 'bargi',
1035
1033
  student: 'oahppi'
1036
1034
  },
1037
1035
  buttonLogIn: 'Logge sisa Feide bokte',
@@ -29,8 +29,6 @@ declare const messages: {
29
29
  loggedInAsButton: string;
30
30
  role: {
31
31
  employee: string;
32
- faculty: string;
33
- staff: string;
34
32
  student: string;
35
33
  };
36
34
  buttonLogIn: string;
@@ -1030,8 +1030,6 @@ var messages = _objectSpread(_objectSpread({
1030
1030
  loggedInAsButton: 'Datne tjaangeme goh {{role}}',
1031
1031
  role: {
1032
1032
  employee: 'barkije',
1033
- faculty: 'barkije',
1034
- staff: 'barkije',
1035
1033
  student: 'learohke'
1036
1034
  },
1037
1035
  buttonLogIn: 'Tjaangh Feidine',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ndla/ui",
3
- "version": "44.0.12",
3
+ "version": "44.0.14",
4
4
  "description": "UI component library for NDLA.",
5
5
  "license": "GPL-3.0",
6
6
  "main": "lib/index.js",
@@ -31,23 +31,23 @@
31
31
  "types"
32
32
  ],
33
33
  "dependencies": {
34
- "@ndla/accordion": "^2.2.19",
34
+ "@ndla/accordion": "^2.2.20",
35
35
  "@ndla/article-scripts": "^3.0.20",
36
- "@ndla/button": "^11.0.4",
37
- "@ndla/carousel": "^3.1.14",
38
- "@ndla/core": "^4.1.5",
39
- "@ndla/dropdown-menu": "^1.0.3",
40
- "@ndla/forms": "^4.3.19",
36
+ "@ndla/button": "^11.0.5",
37
+ "@ndla/carousel": "^3.1.15",
38
+ "@ndla/core": "^4.1.6",
39
+ "@ndla/dropdown-menu": "^1.0.4",
40
+ "@ndla/forms": "^4.3.20",
41
41
  "@ndla/hooks": "^2.0.9",
42
- "@ndla/icons": "^4.0.4",
42
+ "@ndla/icons": "^4.0.5",
43
43
  "@ndla/licenses": "^7.1.3",
44
- "@ndla/modal": "^4.0.3",
45
- "@ndla/notion": "^5.0.18",
46
- "@ndla/safelink": "^4.1.18",
47
- "@ndla/select": "^2.4.10",
48
- "@ndla/switch": "^1.1.10",
49
- "@ndla/tabs": "^3.0.6",
50
- "@ndla/tooltip": "^4.1.16",
44
+ "@ndla/modal": "^4.0.4",
45
+ "@ndla/notion": "^5.0.19",
46
+ "@ndla/safelink": "^4.1.19",
47
+ "@ndla/select": "^2.4.11",
48
+ "@ndla/switch": "^1.1.11",
49
+ "@ndla/tabs": "^3.0.7",
50
+ "@ndla/tooltip": "^4.1.17",
51
51
  "@ndla/util": "^3.1.15",
52
52
  "@radix-ui/react-popover": "^1.0.6",
53
53
  "@radix-ui/react-slider": "^1.1.2",
@@ -83,5 +83,5 @@
83
83
  "publishConfig": {
84
84
  "access": "public"
85
85
  },
86
- "gitHead": "34623f3f23a922343d9de9746ea901cf1e2065ce"
86
+ "gitHead": "46509feeae4e5652f1499768435b9a8357a759c0"
87
87
  }
@@ -32,6 +32,7 @@ const BlockWrapper = styled.div`
32
32
  font-family: ${fonts.sans};
33
33
  border-radius: ${misc.borderRadius};
34
34
  border: 1px solid ${colors.brand.lighter};
35
+ background-color: ${colors.white};
35
36
  max-width: 348px;
36
37
  & ~ & {
37
38
  margin-top: ${spacing.medium};
@@ -34,6 +34,7 @@ const StyledSafeLink = styled(SafeLink)`
34
34
  align-items: center;
35
35
  box-shadow: none;
36
36
  color: inherit;
37
+ background-color: ${colors.white};
37
38
  border: 1px solid ${colors.brand.lighter};
38
39
  padding: ${spacing.normal};
39
40
  ${mq.range({ from: breakpoints.tabletWide })} {
@@ -13,52 +13,20 @@ import { ReactNode } from 'react';
13
13
  import { MessageBanner } from '../Messages';
14
14
  import SkipToMainContent from './SkipToMainContent';
15
15
 
16
- interface MastheadItemProps {
17
- children?: ReactNode;
18
- right?: boolean;
19
- left?: boolean;
20
- }
21
-
22
- const LeftMastheadItem = styled.div`
23
- display: flex;
24
- align-items: center;
25
- button {
26
- white-space: nowrap;
27
- }
28
- > div:last-child {
29
- flex-grow: 1;
30
- }
31
- ${mq.range({ from: breakpoints.desktop })} {
32
- flex-grow: 1;
33
- text-align: left;
34
- }
35
- `;
36
-
37
- const RightMastheadItem = styled.div`
38
- display: flex;
39
- gap: ${spacing.small};
40
- align-items: center;
41
- justify-content: flex-end;
42
- ${mq.range({ from: breakpoints.tablet })} {
43
- padding: ${spacing.small} 0;
44
- padding: 0;
45
- }
46
- `;
47
-
48
- export const MastheadItem = ({ children, left = false, right = false }: MastheadItemProps) => {
49
- const Wrapper = left ? LeftMastheadItem : right ? RightMastheadItem : 'div';
50
- return <Wrapper>{children}</Wrapper>;
51
- };
52
-
53
16
  const MastheadContent = styled.div`
54
17
  justify-content: center;
55
18
  align-items: center;
56
19
  text-align: center;
57
- padding: ${spacing.small};
20
+ padding: ${spacing.small} ${spacing.normal};
58
21
  font-weight: ${fonts.weight.normal};
59
22
  display: flex;
60
23
  height: 84px;
61
24
  justify-content: space-between;
25
+ gap: ${spacing.xsmall};
26
+ ${mq.range({ until: breakpoints.tablet })} {
27
+ padding: ${spacing.small};
28
+ gap: ${spacing.xsmall};
29
+ }
62
30
  `;
63
31
 
64
32
  interface StyledMastheadProps {
@@ -10,7 +10,6 @@ import ToggleSearchButton from '../Search/ToggleSearchButton';
10
10
  interface Props {
11
11
  onClose: VoidFunction;
12
12
  children: (arg: () => void) => ReactNode;
13
- hideOnNarrowScreen?: boolean;
14
13
  ndlaFilm?: boolean;
15
14
  }
16
15
 
@@ -60,7 +59,7 @@ const StyledHeader = styled.div`
60
59
  }
61
60
  `;
62
61
 
63
- const MastheadSearchModal = ({ onClose: onSearchClose, children, hideOnNarrowScreen, ndlaFilm }: Props) => {
62
+ const MastheadSearchModal = ({ onClose: onSearchClose, children, ndlaFilm }: Props) => {
64
63
  const { t } = useTranslation();
65
64
  const [isOpen, setIsOpen] = useState(false);
66
65
 
@@ -72,7 +71,7 @@ const MastheadSearchModal = ({ onClose: onSearchClose, children, hideOnNarrowScr
72
71
  return (
73
72
  <Modal open={isOpen} onOpenChange={setIsOpen}>
74
73
  <ModalTrigger>
75
- <ToggleSearchButton hideOnNarrowScreen={hideOnNarrowScreen} onClick={() => setIsOpen(true)} ndlaFilm={ndlaFilm}>
74
+ <ToggleSearchButton onClick={() => setIsOpen(true)} ndlaFilm={ndlaFilm}>
76
75
  {t('masthead.menu.search')}
77
76
  </ToggleSearchButton>
78
77
  </ModalTrigger>
@@ -6,11 +6,11 @@
6
6
  *
7
7
  */
8
8
 
9
- import Masthead, { MastheadItem } from './Masthead';
9
+ import Masthead from './Masthead';
10
10
 
11
11
  import { getMastheadHeight, useMastheadHeight } from './utils';
12
12
  import { default as SkipToMainContent } from './SkipToMainContent';
13
13
 
14
- export { MastheadItem, getMastheadHeight, useMastheadHeight, SkipToMainContent };
14
+ export { getMastheadHeight, useMastheadHeight, SkipToMainContent };
15
15
 
16
16
  export default Masthead;
@@ -86,8 +86,8 @@ const StyledTitle = styled.span`
86
86
  const ProgrammeCard = ({ title, narrowImage, wideImage, url }: Programme) => {
87
87
  return (
88
88
  <StyledCardContainer to={url}>
89
- {narrowImage && <StyledImg data-is-mobile="false" src={narrowImage.src} loading="lazy" alt={narrowImage.alt} />}
90
- {wideImage && <StyledImg data-is-mobile="true" src={wideImage.src} loading="lazy" alt={wideImage.alt} />}
89
+ {narrowImage && <StyledImg data-is-mobile="false" src={narrowImage.src} alt={narrowImage.alt} />}
90
+ {wideImage && <StyledImg data-is-mobile="true" src={wideImage.src} alt={wideImage.alt} />}
91
91
  <StyledTitle>{title.title}</StyledTitle>
92
92
  </StyledCardContainer>
93
93
  );
@@ -7,48 +7,37 @@
7
7
  */
8
8
 
9
9
  import { forwardRef } from 'react';
10
- import { spacing, spacingUnit, breakpoints, mq, misc, fonts, colors } from '@ndla/core';
10
+ import { spacing, breakpoints, mq, misc, fonts, colors } from '@ndla/core';
11
11
  import { Search } from '@ndla/icons/common';
12
12
  import { ButtonProps, ButtonV2 } from '@ndla/button';
13
13
  import styled from '@emotion/styled';
14
14
 
15
15
  interface Props extends ButtonProps {
16
- hideOnNarrowScreen?: boolean;
17
- hideOnWideScreen?: boolean;
18
16
  ndlaFilm?: boolean;
19
17
  }
20
18
 
21
- interface StyledButtonProps {
22
- hideOnNarrowScreen?: boolean;
23
- hideOnWideScreen?: boolean;
24
- ndlaFilm?: boolean;
25
- }
26
-
27
- const props = ['hideOnNarrowScreen', 'hideOnWideScreen', 'ndlaFilm'];
28
-
29
- const shouldForwardProp = (p: string) => !props.includes(p);
30
-
31
- const StyledButton = styled(ButtonV2, { shouldForwardProp })<StyledButtonProps>`
32
- background: ${(p) => (p.ndlaFilm ? colors.ndlaFilm.filmColorBright : colors.brand.greyLighter)};
19
+ const StyledButton = styled(ButtonV2)`
33
20
  border-radius: ${misc.borderRadius};
34
21
  border: 0;
35
- display: ${(p) => (p.hideOnNarrowScreen ? 'none' : 'flex')};
36
- color: ${(p) => (p.ndlaFilm ? '#fff' : colors.brand.primary)};
37
- padding: ${spacing.small} ${spacingUnit * 0.75}px ${spacing.small} ${spacing.normal};
22
+ color: ${colors.brand.primary};
38
23
  align-items: center;
39
- margin-left: ${spacing.medium};
24
+ background: transparent;
40
25
 
41
- .c-icon {
26
+ svg {
42
27
  height: 24px;
43
28
  width: 24px;
44
29
  }
45
30
 
46
31
  ${fonts.sizes('16px', '32px')};
47
32
 
48
- ${mq.range({ from: breakpoints.desktop })} {
49
- display: ${(p) => (p.hideOnWideScreen ? 'none' : 'flex')};
50
- margin-right: ${spacing.nsmall};
33
+ &[data-film='true'] {
34
+ background: ${colors.ndlaFilm.filmColorBright};
35
+ color: ${colors.white};
36
+ }
37
+
38
+ ${mq.range({ from: breakpoints.tabletWide })} {
51
39
  padding: ${spacing.small} ${spacing.normal};
40
+ background: ${colors.brand.greyLighter};
52
41
  }
53
42
  &:hover,
54
43
  &:focus,
@@ -60,22 +49,16 @@ const StyledButton = styled(ButtonV2, { shouldForwardProp })<StyledButtonProps>`
60
49
  const StyledSpan = styled.span`
61
50
  margin-right: ${spacing.normal};
62
51
  font-weight: ${fonts.weight.normal};
52
+ ${mq.range({ until: breakpoints.tabletWide })} {
53
+ display: none;
54
+ }
63
55
  `;
64
56
 
65
- const ToggleSearchButton = forwardRef<HTMLButtonElement, Props>(
66
- ({ children, ndlaFilm, hideOnNarrowScreen, hideOnWideScreen, ...rest }, ref) => (
67
- <StyledButton
68
- ndlaFilm={ndlaFilm}
69
- hideOnNarrowScreen={hideOnNarrowScreen}
70
- hideOnWideScreen={hideOnWideScreen}
71
- type="button"
72
- ref={ref}
73
- {...rest}
74
- >
75
- <StyledSpan>{children}</StyledSpan>
76
- <Search />
77
- </StyledButton>
78
- ),
79
- );
57
+ const ToggleSearchButton = forwardRef<HTMLButtonElement, Props>(({ children, ndlaFilm, ...rest }, ref) => (
58
+ <StyledButton data-film={ndlaFilm} type="button" ref={ref} {...rest}>
59
+ <StyledSpan>{children}</StyledSpan>
60
+ <Search />
61
+ </StyledButton>
62
+ ));
80
63
 
81
64
  export default ToggleSearchButton;
@@ -6,16 +6,14 @@
6
6
  *
7
7
  */
8
8
 
9
+ import { css } from '@emotion/react';
9
10
  import styled from '@emotion/styled';
10
- import { colors, spacing } from '@ndla/core';
11
+ import { breakpoints, colors, fonts, mq, spacing } from '@ndla/core';
11
12
  import throttle from 'lodash/throttle';
12
13
  import { ReactNode, UIEvent, useCallback, useEffect, useMemo, useRef, useState } from 'react';
13
- import BEMHelper from 'react-bem-helper';
14
14
 
15
15
  type ScrollPosition = 'start' | 'end' | 'center';
16
16
 
17
- const classes = BEMHelper('c-table');
18
-
19
17
  const MARGIN = 5;
20
18
 
21
19
  interface Props {
@@ -26,17 +24,17 @@ interface Props {
26
24
  };
27
25
  }
28
26
 
29
- interface StyledProps {
30
- show: boolean;
31
- }
32
-
33
- const ScrollBorder = styled.div<StyledProps>`
27
+ const ScrollBorder = styled.div`
34
28
  position: absolute;
35
29
  top: 0;
36
30
  height: calc(100% - ${spacing.mediumlarge});
37
31
  width: 3px;
38
32
  background: ${colors.background.dark};
39
- display: ${({ show }) => (show ? 'block' : 'none')};
33
+ display: none;
34
+
35
+ &[data-block='true'] {
36
+ display: block;
37
+ }
40
38
  `;
41
39
 
42
40
  const RightScrollBorder = styled(ScrollBorder)`
@@ -47,6 +45,158 @@ const LeftScrollBorder = styled(ScrollBorder)`
47
45
  left: 0;
48
46
  `;
49
47
 
48
+ export const TableStyling = css`
49
+ &::-webkit-scrollbar {
50
+ height: ${spacing.xsmall};
51
+ }
52
+ &::-webkit-scrollbar-track-piece {
53
+ background: ${colors.brand.lighter};
54
+ border-radius: ${spacing.xsmall};
55
+ }
56
+ &::-webkit-scrollbar-thumb {
57
+ background: ${colors.brand.dark};
58
+ border-radius: ${spacing.xsmall};
59
+ }
60
+ display: inline-block;
61
+
62
+ font-size: 85%;
63
+ max-width: 100%;
64
+
65
+ padding-left: ${spacing.xxsmall};
66
+ padding-right: ${spacing.xxsmall};
67
+
68
+ vertical-align: top;
69
+ table-layout: fixed;
70
+ overflow-x: auto;
71
+
72
+ // optional - enable iOS momentum scrolling
73
+ -webkit-overflow-scrolling: touch;
74
+
75
+ // scrolling shadows on left/right
76
+ &:after,
77
+ &:before {
78
+ content: '';
79
+ display: table;
80
+ clear: both;
81
+ }
82
+
83
+ > caption {
84
+ background-color: transparent;
85
+ font-weight: ${fonts.weight.bold};
86
+ font-family: ${fonts.sans};
87
+ ${fonts.sizes('16px', '20px')}
88
+ text-align: left;
89
+ text-transform: uppercase;
90
+ margin-bottom: ${spacing.small};
91
+ }
92
+
93
+ thead {
94
+ overflow: hidden;
95
+ }
96
+
97
+ thead tr td,
98
+ th {
99
+ font-weight: ${fonts.weight.bold};
100
+ border-bottom: 3px solid ${colors.brand.tertiary};
101
+ font-family: ${fonts.sans};
102
+ vertical-align: text-top;
103
+
104
+ ${fonts.sizes('16px', '22px')};
105
+ ${mq.range({ from: breakpoints.tablet })} {
106
+ ${fonts.sizes('16px', '30px')};
107
+ }
108
+ }
109
+
110
+ tbody th {
111
+ border-bottom: 0;
112
+ border-right: 3px solid ${colors.brand.tertiary};
113
+ padding: ${spacing.xsmall};
114
+ }
115
+
116
+ thead tr:nth-child(2) th {
117
+ border: 1px solid ${colors.brand.lighter};
118
+ text-transform: none;
119
+
120
+ ${fonts.sizes('14px', '18px')};
121
+ ${mq.range({ from: breakpoints.tablet })} {
122
+ ${fonts.sizes('15px', '26px')};
123
+ }
124
+
125
+ font-weight: ${fonts.weight.semibold};
126
+ height: 40px;
127
+ background-color: ${colors.brand.lighter};
128
+ padding: ${spacing.xxsmall} ${spacing.normal} ${spacing.xxsmall} ${spacing.xsmall};
129
+
130
+ &:empty {
131
+ background-color: transparent;
132
+ }
133
+ }
134
+
135
+ td {
136
+ border: 1px solid ${colors.brand.lighter};
137
+ vertical-align: top;
138
+
139
+ ${fonts.sizes('14px', '22px')};
140
+ ${mq.range({ from: breakpoints.tablet })} {
141
+ ${fonts.sizes('15px', '30px')};
142
+ }
143
+
144
+ ol,
145
+ ul {
146
+ font-size: unset !important;
147
+ }
148
+
149
+ p {
150
+ line-height: 1.6em;
151
+ }
152
+
153
+ p:last-child {
154
+ margin: 0;
155
+ }
156
+
157
+ img {
158
+ max-width: 100%;
159
+ min-width: 120px;
160
+ }
161
+ }
162
+
163
+ td,
164
+ th {
165
+ display: table-cell;
166
+ padding: ${spacing.xsmall} ${spacing.small};
167
+
168
+ p {
169
+ margin: 0;
170
+ }
171
+ }
172
+
173
+ // Remove excess spacing on headings inside table
174
+ h1,
175
+ h2,
176
+ h3,
177
+ h4,
178
+ h5 {
179
+ margin-top: 0;
180
+ }
181
+
182
+ ul {
183
+ margin: 0 0 0 ${spacing.nsmall};
184
+ }
185
+
186
+ .c-figure {
187
+ margin: 0;
188
+ padding: 0;
189
+ width: 100% !important;
190
+ left: 0 !important;
191
+ }
192
+ `;
193
+
194
+ const TableWrapper = styled.div`
195
+ display: flex;
196
+ justify-content: center;
197
+ margin: ${spacing.small} 0;
198
+ `;
199
+
50
200
  const Table = ({ children, id, ...rest }: Props) => {
51
201
  const [scrollPosition, setScrollPosition] = useState<ScrollPosition | undefined>(undefined);
52
202
  const tableRef = useRef<HTMLTableElement>(null);
@@ -91,18 +241,15 @@ const Table = ({ children, id, ...rest }: Props) => {
91
241
  }, [checkScrollPosition]);
92
242
 
93
243
  return (
94
- <div {...classes('wrapper')}>
95
- <div {...classes('content')}>
96
- <LeftScrollBorder show={scrollPosition === 'end' || scrollPosition === 'center'} {...classes('left-shadow')} />
97
- <table ref={tableRef} id={id} onScroll={onScroll} {...classes({ extra: ['o-table'] })} {...rest}>
244
+ <TableWrapper>
245
+ <div>
246
+ <LeftScrollBorder data-block={scrollPosition === 'end' || scrollPosition === 'center'} />
247
+ <table ref={tableRef} id={id} onScroll={onScroll} css={TableStyling} {...rest}>
98
248
  {children}
99
249
  </table>
100
- <RightScrollBorder
101
- show={scrollPosition === 'start' || scrollPosition === 'center'}
102
- {...classes('right-shadow')}
103
- />
250
+ <RightScrollBorder data-block={scrollPosition === 'start' || scrollPosition === 'center'} />
104
251
  </div>
105
- </div>
252
+ </TableWrapper>
106
253
  );
107
254
  };
108
255
 
@@ -8,4 +8,5 @@
8
8
 
9
9
  import Table from './Table';
10
10
 
11
+ export { TableStyling } from './Table';
11
12
  export default Table;