@ndla/ui 44.0.12 → 44.0.13
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/es/ContactBlock/ContactBlock.js +13 -13
- package/es/LinkBlock/LinkBlock.js +6 -6
- package/es/Masthead/Masthead.js +13 -34
- package/es/Masthead/MastheadSearchModal.js +2 -4
- package/es/Masthead/index.js +2 -2
- package/es/Search/ToggleSearchButton.js +9 -24
- package/es/Table/Table.js +36 -30
- package/es/Table/index.js +1 -0
- package/es/User/UserInfo.js +6 -3
- package/es/User/parseUserObject.js +1 -1
- package/es/all.css +1 -1
- package/es/index.js +2 -2
- package/es/locale/messages-en.js +0 -2
- package/es/locale/messages-nb.js +0 -2
- package/es/locale/messages-nn.js +0 -2
- package/es/locale/messages-se.js +0 -2
- package/es/locale/messages-sma.js +0 -2
- package/lib/ContactBlock/ContactBlock.js +13 -13
- package/lib/LinkBlock/LinkBlock.js +6 -6
- package/lib/Masthead/Masthead.d.ts +0 -6
- package/lib/Masthead/Masthead.js +14 -36
- package/lib/Masthead/MastheadSearchModal.d.ts +1 -2
- package/lib/Masthead/MastheadSearchModal.js +2 -4
- package/lib/Masthead/index.d.ts +2 -2
- package/lib/Masthead/index.js +1 -10
- package/lib/Search/ToggleSearchButton.d.ts +0 -2
- package/lib/Search/ToggleSearchButton.js +8 -23
- package/lib/Table/Table.d.ts +1 -0
- package/lib/Table/Table.js +43 -36
- package/lib/Table/index.d.ts +1 -0
- package/lib/Table/index.js +10 -2
- package/lib/User/UserInfo.js +6 -3
- package/lib/User/parseUserObject.d.ts +1 -1
- package/lib/User/parseUserObject.js +1 -1
- package/lib/all.css +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.js +7 -7
- package/lib/locale/messages-en.d.ts +0 -2
- package/lib/locale/messages-en.js +0 -2
- package/lib/locale/messages-nb.d.ts +0 -2
- package/lib/locale/messages-nb.js +0 -2
- package/lib/locale/messages-nn.d.ts +0 -2
- package/lib/locale/messages-nn.js +0 -2
- package/lib/locale/messages-se.d.ts +0 -2
- package/lib/locale/messages-se.js +0 -2
- package/lib/locale/messages-sma.d.ts +0 -2
- package/lib/locale/messages-sma.js +0 -2
- package/package.json +16 -16
- package/src/ContactBlock/ContactBlock.tsx +1 -0
- package/src/LinkBlock/LinkBlock.tsx +1 -0
- package/src/Masthead/Masthead.tsx +6 -38
- package/src/Masthead/MastheadSearchModal.tsx +2 -3
- package/src/Masthead/index.ts +2 -2
- package/src/Search/ToggleSearchButton.tsx +21 -38
- package/src/Table/Table.tsx +166 -19
- package/src/Table/index.ts +1 -0
- package/src/User/UserInfo.tsx +3 -1
- package/src/User/__tests__/parseUserObject-test.ts +1 -1
- package/src/User/parseUserObject.ts +1 -1
- package/src/index.ts +2 -2
- package/src/locale/messages-en.ts +0 -2
- package/src/locale/messages-nb.ts +0 -2
- package/src/locale/messages-nn.ts +0 -2
- package/src/locale/messages-se.ts +0 -2
- package/src/locale/messages-sma.ts +0 -2
- package/src/main.scss +0 -1
- 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,
|
|
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 =
|
|
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"));
|
|
@@ -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',
|
|
@@ -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',
|
|
@@ -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',
|
|
@@ -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',
|
|
@@ -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.
|
|
3
|
+
"version": "44.0.13",
|
|
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.
|
|
34
|
+
"@ndla/accordion": "^2.2.20",
|
|
35
35
|
"@ndla/article-scripts": "^3.0.20",
|
|
36
|
-
"@ndla/button": "^11.0.
|
|
37
|
-
"@ndla/carousel": "^3.1.
|
|
38
|
-
"@ndla/core": "^4.1.
|
|
39
|
-
"@ndla/dropdown-menu": "^1.0.
|
|
40
|
-
"@ndla/forms": "^4.3.
|
|
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.
|
|
42
|
+
"@ndla/icons": "^4.0.5",
|
|
43
43
|
"@ndla/licenses": "^7.1.3",
|
|
44
|
-
"@ndla/modal": "^4.0.
|
|
45
|
-
"@ndla/notion": "^5.0.
|
|
46
|
-
"@ndla/safelink": "^4.1.
|
|
47
|
-
"@ndla/select": "^2.4.
|
|
48
|
-
"@ndla/switch": "^1.1.
|
|
49
|
-
"@ndla/tabs": "^3.0.
|
|
50
|
-
"@ndla/tooltip": "^4.1.
|
|
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": "
|
|
86
|
+
"gitHead": "385f883c00df1b1a5818d687cb27373981783ec6"
|
|
87
87
|
}
|
|
@@ -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,
|
|
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
|
|
74
|
+
<ToggleSearchButton onClick={() => setIsOpen(true)} ndlaFilm={ndlaFilm}>
|
|
76
75
|
{t('masthead.menu.search')}
|
|
77
76
|
</ToggleSearchButton>
|
|
78
77
|
</ModalTrigger>
|
package/src/Masthead/index.ts
CHANGED
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import 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 {
|
|
14
|
+
export { getMastheadHeight, useMastheadHeight, SkipToMainContent };
|
|
15
15
|
|
|
16
16
|
export default Masthead;
|
|
@@ -7,48 +7,37 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { forwardRef } from 'react';
|
|
10
|
-
import { spacing,
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
24
|
+
background: transparent;
|
|
40
25
|
|
|
41
|
-
|
|
26
|
+
svg {
|
|
42
27
|
height: 24px;
|
|
43
28
|
width: 24px;
|
|
44
29
|
}
|
|
45
30
|
|
|
46
31
|
${fonts.sizes('16px', '32px')};
|
|
47
32
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
|
|
67
|
-
<
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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;
|
package/src/Table/Table.tsx
CHANGED
|
@@ -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
|
-
|
|
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:
|
|
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
|
-
<
|
|
95
|
-
<div
|
|
96
|
-
<LeftScrollBorder
|
|
97
|
-
<table ref={tableRef} id={id} onScroll={onScroll} {
|
|
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
|
-
</
|
|
252
|
+
</TableWrapper>
|
|
106
253
|
);
|
|
107
254
|
};
|
|
108
255
|
|
package/src/Table/index.ts
CHANGED
package/src/User/UserInfo.tsx
CHANGED
|
@@ -23,6 +23,8 @@ const ShortInfoDiv = styled.div`
|
|
|
23
23
|
margin: 2rem auto;
|
|
24
24
|
`;
|
|
25
25
|
|
|
26
|
+
const isTeacher = (affiliations: FeideUserApiType['eduPersonAffiliation']) => affiliations.includes('employee');
|
|
27
|
+
|
|
26
28
|
export const UserInfo = ({ user }: Props) => {
|
|
27
29
|
const { t } = useTranslation();
|
|
28
30
|
|
|
@@ -33,7 +35,7 @@ export const UserInfo = ({ user }: Props) => {
|
|
|
33
35
|
{
|
|
34
36
|
<p>
|
|
35
37
|
{t('user.loggedInAs', {
|
|
36
|
-
role: t(`user.role.${parsedUser.
|
|
38
|
+
role: t(`user.role.${isTeacher(parsedUser.eduPersonAffiliation) ? 'employee' : 'student'}`),
|
|
37
39
|
})}
|
|
38
40
|
</p>
|
|
39
41
|
}
|
|
@@ -162,9 +162,9 @@ describe('parseUserObject', () => {
|
|
|
162
162
|
it('Correctly parses Feide user', () => {
|
|
163
163
|
const expected = {
|
|
164
164
|
uid: ['david_laerervgs'],
|
|
165
|
-
primaryAffiliation: 'employee',
|
|
166
165
|
displayName: 'David LærerVGS Jonsen',
|
|
167
166
|
mail: ['david_laerervgs@feide.no'],
|
|
167
|
+
eduPersonAffiliation: ['member', 'employee', 'faculty'],
|
|
168
168
|
grepCodes: [],
|
|
169
169
|
organizations: [
|
|
170
170
|
{
|