@ndla/ui 30.6.0 → 30.7.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/lib/index.d.ts CHANGED
@@ -95,3 +95,4 @@ export { InfoBlock } from './InfoBlock';
95
95
  export { TreeStructure } from './TreeStructure';
96
96
  export type { FolderType, TreeStructureProps } from './TreeStructure';
97
97
  export { SearchField, SearchResultList, SearchResultItem, ActiveFilters, ToggleSearchButton } from './Search';
98
+ export { default as LetterFilter } from './LetterFilter';
package/lib/index.js CHANGED
@@ -199,7 +199,8 @@ var _exportNames = {
199
199
  SearchResultList: true,
200
200
  SearchResultItem: true,
201
201
  ActiveFilters: true,
202
- ToggleSearchButton: true
202
+ ToggleSearchButton: true,
203
+ LetterFilter: true
203
204
  };
204
205
  Object.defineProperty(exports, "AboutNdlaFilm", {
205
206
  enumerable: true,
@@ -759,6 +760,12 @@ Object.defineProperty(exports, "LearningPathWrapper", {
759
760
  return _LearningPaths.LearningPathWrapper;
760
761
  }
761
762
  });
763
+ Object.defineProperty(exports, "LetterFilter", {
764
+ enumerable: true,
765
+ get: function get() {
766
+ return _LetterFilter["default"];
767
+ }
768
+ });
762
769
  Object.defineProperty(exports, "ListResource", {
763
770
  enumerable: true,
764
771
  get: function get() {
@@ -1458,6 +1465,7 @@ var _SnackBar = require("./SnackBar");
1458
1465
  var _InfoBlock = require("./InfoBlock");
1459
1466
  var _TreeStructure = require("./TreeStructure");
1460
1467
  var _Search = require("./Search");
1468
+ var _LetterFilter = _interopRequireDefault(require("./LetterFilter"));
1461
1469
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
1462
1470
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
1463
1471
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ndla/ui",
3
- "version": "30.6.0",
3
+ "version": "30.7.0",
4
4
  "description": "UI component library for NDLA.",
5
5
  "license": "GPL-3.0",
6
6
  "main": "lib/index.js",
@@ -32,19 +32,19 @@
32
32
  ],
33
33
  "dependencies": {
34
34
  "@ndla/article-scripts": "^3.0.9",
35
- "@ndla/button": "^5.2.0",
36
- "@ndla/carousel": "^2.0.5",
37
- "@ndla/core": "^3.0.0",
38
- "@ndla/forms": "^4.0.11",
35
+ "@ndla/button": "^6.0.0",
36
+ "@ndla/carousel": "^2.0.6",
37
+ "@ndla/core": "^3.0.1",
38
+ "@ndla/forms": "^4.0.12",
39
39
  "@ndla/hooks": "^1.1.13",
40
- "@ndla/icons": "^2.0.5",
41
- "@ndla/licenses": "^6.0.5",
42
- "@ndla/modal": "^2.1.0",
43
- "@ndla/notion": "^4.0.12",
44
- "@ndla/safelink": "^3.0.11",
45
- "@ndla/switch": "^1.0.0",
46
- "@ndla/tabs": "^2.0.7",
47
- "@ndla/tooltip": "^3.0.1",
40
+ "@ndla/icons": "^2.0.6",
41
+ "@ndla/licenses": "^6.0.6",
42
+ "@ndla/modal": "^2.1.1",
43
+ "@ndla/notion": "^4.0.13",
44
+ "@ndla/safelink": "^3.0.12",
45
+ "@ndla/switch": "^1.0.1",
46
+ "@ndla/tabs": "^2.0.8",
47
+ "@ndla/tooltip": "^3.0.2",
48
48
  "@ndla/types-learningpath-api": "^0.0.13",
49
49
  "@ndla/util": "^3.1.7",
50
50
  "@reach/menu-button": "^0.16.2",
@@ -86,5 +86,5 @@
86
86
  "publishConfig": {
87
87
  "access": "public"
88
88
  },
89
- "gitHead": "e1afd33a2d6aec21ea78153251643f8a79164c4e"
89
+ "gitHead": "ca95292ccece036a5da6c3d4b5c494b35171a71f"
90
90
  }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Copyright (c) 2022-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import { ComponentStory, ComponentMeta } from '@storybook/react';
10
+ import { useArgs } from '@storybook/client-api';
11
+ import React from 'react';
12
+ import { defaultParameters } from '../../../designmanual/stories/defaults';
13
+ import LetterFilter from './LetterFilter';
14
+
15
+ export default {
16
+ title: 'Enkle komponenter/LetterFilter',
17
+ component: LetterFilter,
18
+ parameters: {
19
+ ...defaultParameters,
20
+ },
21
+ args: {
22
+ enabledLetters: ['a', 'c'],
23
+ onChange: (value?: string) => {},
24
+ },
25
+ } as ComponentMeta<typeof LetterFilter>;
26
+
27
+ export const LetterFilterStory: ComponentStory<typeof LetterFilter> = (args) => {
28
+ const [, updateArgs] = useArgs();
29
+
30
+ return <LetterFilter {...args} onChange={(val) => updateArgs({ value: val })} />;
31
+ };
32
+
33
+ LetterFilterStory.storyName = 'LetterFilter';
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Copyright (c) 2022-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import styled from '@emotion/styled';
10
+ import React, { useMemo } from 'react';
11
+ import { colors, fonts, spacing } from '@ndla/core';
12
+ import { useTranslation } from 'react-i18next';
13
+ import { IconButtonV2 as IconButton } from '@ndla/button';
14
+ import { alphabet } from './alphabet';
15
+
16
+ const StyledUL = styled.ul`
17
+ list-style: none;
18
+ display: flex;
19
+ flex-direction: row;
20
+ flex-wrap: wrap;
21
+ gap: ${spacing.xsmall};
22
+ `;
23
+
24
+ const StyledButton = styled(IconButton)`
25
+ display: flex;
26
+ align-items: center;
27
+ justify-content: center;
28
+ width: ${spacing.normal};
29
+ height: ${spacing.normal};
30
+ padding: 0;
31
+ ${fonts.sizes(18)};
32
+ && {
33
+ font-weight: ${fonts.weight.semibold};
34
+ }
35
+
36
+ :disabled {
37
+ pointer-events: none;
38
+ color: ${colors.brand.light};
39
+ }
40
+ `;
41
+
42
+ interface Props {
43
+ value?: string | undefined;
44
+ onChange: (value?: string) => void;
45
+ enabledLetters: string[];
46
+ }
47
+
48
+ const LetterFilter = ({ value, onChange, enabledLetters }: Props) => {
49
+ const { t } = useTranslation();
50
+ const uppercaseLetters = useMemo(() => enabledLetters.map((letter) => letter.toUpperCase()), [enabledLetters]);
51
+
52
+ return (
53
+ <StyledUL>
54
+ {alphabet.map((letter) => {
55
+ const disabled = !uppercaseLetters.includes(letter.toUpperCase());
56
+ const selected = letter.toUpperCase() === value?.toUpperCase();
57
+ return (
58
+ <li key={letter}>
59
+ <StyledButton
60
+ onClick={() => (selected ? onChange(undefined) : onChange(letter))}
61
+ aria-label={t('listview.filters.alphabet.letterFilter', { letter })}
62
+ variant={!selected ? 'ghost' : undefined}
63
+ colorTheme={!selected ? 'lighter' : 'primary'}
64
+ disabled={disabled}
65
+ size="xsmall">
66
+ {letter}
67
+ </StyledButton>
68
+ </li>
69
+ );
70
+ })}
71
+ </StyledUL>
72
+ );
73
+ };
74
+
75
+ export default LetterFilter;
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Copyright (c) 2022-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ export const alphabet = [
10
+ 'A',
11
+ 'B',
12
+ 'C',
13
+ 'D',
14
+ 'E',
15
+ 'F',
16
+ 'G',
17
+ 'H',
18
+ 'I',
19
+ 'J',
20
+ 'K',
21
+ 'L',
22
+ 'M',
23
+ 'N',
24
+ 'O',
25
+ 'P',
26
+ 'Q',
27
+ 'R',
28
+ 'S',
29
+ 'T',
30
+ 'U',
31
+ 'V',
32
+ 'W',
33
+ 'X',
34
+ 'Y',
35
+ 'Z',
36
+ 'Æ',
37
+ 'Ø',
38
+ 'Å',
39
+ ];
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Copyright (c) 2022-present, NDLA.
3
+ *
4
+ * This source code is licensed under the GPLv3 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import LetterFilter from './LetterFilter';
10
+
11
+ export default LetterFilter;
@@ -80,4 +80,5 @@ export interface FeideUser {
80
80
  export interface FeideUserApiType extends FeideUser {
81
81
  groups: FeideGroup[];
82
82
  primarySchool?: FeideGroup;
83
+ baseOrg?: FeideGroup;
83
84
  }
package/src/index.ts CHANGED
@@ -254,3 +254,4 @@ export { TreeStructure } from './TreeStructure';
254
254
  export type { FolderType, TreeStructureProps } from './TreeStructure';
255
255
 
256
256
  export { SearchField, SearchResultList, SearchResultItem, ActiveFilters, ToggleSearchButton } from './Search';
257
+ export { default as LetterFilter } from './LetterFilter';