@kth/style 0.2.1 → 0.2.3
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/assets/figtree-italic[wght].woff2 +0 -0
- package/assets/figtree[wght].woff2 +0 -0
- package/assets/fonts.css +13 -0
- package/assets/kth-logotype-blue.png +0 -0
- package/assets/kth-logotype-blue.webp +0 -0
- package/assets/kth-logotype-blue@2x.png +0 -0
- package/assets/kth-logotype-blue@2x.webp +0 -0
- package/assets/kth-logotype-blue@3x.png +0 -0
- package/assets/kth-logotype-blue@3x.webp +0 -0
- package/assets/kth-logotype-blue@4x.png +0 -0
- package/assets/kth-logotype-blue@4x.webp +0 -0
- package/assets/kth-logotype-white.png +0 -0
- package/assets/kth-logotype-white.webp +0 -0
- package/assets/kth-logotype-white@2x.png +0 -0
- package/assets/kth-logotype-white@2x.webp +0 -0
- package/assets/kth-logotype-white@3x.png +0 -0
- package/assets/kth-logotype-white@3x.webp +0 -0
- package/assets/kth-logotype-white@4x.png +0 -0
- package/assets/kth-logotype-white@4x.webp +0 -0
- package/dist/cjs/components/react/DropdownWithPanel.d.ts +8 -0
- package/dist/cjs/react.d.ts +1 -1
- package/dist/cjs/react.js +49 -3
- package/dist/esm/components/react/DropdownWithPanel.d.ts +8 -0
- package/dist/esm/react.d.ts +1 -1
- package/dist/esm/react.js +48 -3
- package/package.json +4 -3
- package/scss/components/details.scss +51 -0
- package/scss/components/header.scss +9 -0
|
Binary file
|
|
Binary file
|
package/assets/fonts.css
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
@font-face {
|
|
2
|
+
font-family: Figtree;
|
|
3
|
+
src: url("figtree[wght].woff2") format("woff2-variations");
|
|
4
|
+
font-weight: 100 900;
|
|
5
|
+
font-style: normal;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
@font-face {
|
|
9
|
+
font-family: Figtree;
|
|
10
|
+
src: url("figtree-italic[wght].woff2") format("woff2-variations");
|
|
11
|
+
font-weight: 100 900;
|
|
12
|
+
font-style: italic;
|
|
13
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface Props {
|
|
3
|
+
label: string;
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
}
|
|
6
|
+
export declare function DropdownWithPanel({ label, children }: Props): React.JSX.Element;
|
|
7
|
+
export declare function DropdownContainer(props: React.HTMLAttributes<HTMLDivElement>): React.JSX.Element;
|
|
8
|
+
export {};
|
package/dist/cjs/react.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { DropdownContainer, DropdownWithPanel, } from "./components/react/DropdownWithPanel";
|
package/dist/cjs/react.js
CHANGED
|
@@ -1,7 +1,53 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
var React = require('react');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Close all <dialog>s (modal and non-modal) in a document
|
|
7
|
+
*/
|
|
8
|
+
function closeAllDialogs() {
|
|
9
|
+
document.querySelectorAll("dialog").forEach((dialog) => dialog.close());
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function DropdownWithPanel({ label, children }) {
|
|
13
|
+
const [shouldRender, setShouldRender] = React.useState(false);
|
|
14
|
+
const dialogRef = React.useRef(null);
|
|
15
|
+
function closeDialog() {
|
|
16
|
+
dialogRef.current?.close();
|
|
17
|
+
}
|
|
18
|
+
function handleKeyDown(event) {
|
|
19
|
+
if (event.key === "Escape") {
|
|
20
|
+
event.stopPropagation();
|
|
21
|
+
dialogRef.current?.close();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return (React.createElement("div", null,
|
|
25
|
+
React.createElement("button", { className: "kth-menu-item dropdown", onClick: () => {
|
|
26
|
+
setShouldRender(true);
|
|
27
|
+
if (!dialogRef.current?.open) {
|
|
28
|
+
closeAllDialogs();
|
|
29
|
+
dialogRef.current?.show();
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
closeAllDialogs();
|
|
33
|
+
}
|
|
34
|
+
}, onMouseOver: () => setShouldRender(true), onFocus: () => setShouldRender(true) },
|
|
35
|
+
React.createElement("span", null, label)),
|
|
36
|
+
React.createElement("dialog", { className: "kth-menu-panel", ref: dialogRef, onKeyDown: handleKeyDown },
|
|
37
|
+
React.createElement("div", { className: "kth-menu-panel__container" },
|
|
38
|
+
React.createElement("button", { className: "kth-button close", onClick: () => closeDialog() },
|
|
39
|
+
React.createElement("span", { className: "kth-visually-hidden" }, "Close")),
|
|
40
|
+
React.createElement("div", { className: "kth-menu-panel__content" }, shouldRender && children)))));
|
|
41
|
+
}
|
|
42
|
+
function DropdownContainer(props) {
|
|
43
|
+
const containerRef = React.useRef(null);
|
|
44
|
+
return (React.createElement("div", { ref: containerRef, onBlur: (event) => {
|
|
45
|
+
const relatedTarget = event.relatedTarget;
|
|
46
|
+
if (relatedTarget && !containerRef.current?.contains(relatedTarget)) {
|
|
47
|
+
closeAllDialogs();
|
|
48
|
+
}
|
|
49
|
+
}, ...props }));
|
|
5
50
|
}
|
|
6
51
|
|
|
7
|
-
|
|
52
|
+
exports.DropdownContainer = DropdownContainer;
|
|
53
|
+
exports.DropdownWithPanel = DropdownWithPanel;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface Props {
|
|
3
|
+
label: string;
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
}
|
|
6
|
+
export declare function DropdownWithPanel({ label, children }: Props): React.JSX.Element;
|
|
7
|
+
export declare function DropdownContainer(props: React.HTMLAttributes<HTMLDivElement>): React.JSX.Element;
|
|
8
|
+
export {};
|
package/dist/esm/react.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { DropdownContainer, DropdownWithPanel, } from "./components/react/DropdownWithPanel";
|
package/dist/esm/react.js
CHANGED
|
@@ -1,5 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Close all <dialog>s (modal and non-modal) in a document
|
|
5
|
+
*/
|
|
6
|
+
function closeAllDialogs() {
|
|
7
|
+
document.querySelectorAll("dialog").forEach((dialog) => dialog.close());
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function DropdownWithPanel({ label, children }) {
|
|
11
|
+
const [shouldRender, setShouldRender] = React.useState(false);
|
|
12
|
+
const dialogRef = React.useRef(null);
|
|
13
|
+
function closeDialog() {
|
|
14
|
+
dialogRef.current?.close();
|
|
15
|
+
}
|
|
16
|
+
function handleKeyDown(event) {
|
|
17
|
+
if (event.key === "Escape") {
|
|
18
|
+
event.stopPropagation();
|
|
19
|
+
dialogRef.current?.close();
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return (React.createElement("div", null,
|
|
23
|
+
React.createElement("button", { className: "kth-menu-item dropdown", onClick: () => {
|
|
24
|
+
setShouldRender(true);
|
|
25
|
+
if (!dialogRef.current?.open) {
|
|
26
|
+
closeAllDialogs();
|
|
27
|
+
dialogRef.current?.show();
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
closeAllDialogs();
|
|
31
|
+
}
|
|
32
|
+
}, onMouseOver: () => setShouldRender(true), onFocus: () => setShouldRender(true) },
|
|
33
|
+
React.createElement("span", null, label)),
|
|
34
|
+
React.createElement("dialog", { className: "kth-menu-panel", ref: dialogRef, onKeyDown: handleKeyDown },
|
|
35
|
+
React.createElement("div", { className: "kth-menu-panel__container" },
|
|
36
|
+
React.createElement("button", { className: "kth-button close", onClick: () => closeDialog() },
|
|
37
|
+
React.createElement("span", { className: "kth-visually-hidden" }, "Close")),
|
|
38
|
+
React.createElement("div", { className: "kth-menu-panel__content" }, shouldRender && children)))));
|
|
39
|
+
}
|
|
40
|
+
function DropdownContainer(props) {
|
|
41
|
+
const containerRef = React.useRef(null);
|
|
42
|
+
return (React.createElement("div", { ref: containerRef, onBlur: (event) => {
|
|
43
|
+
const relatedTarget = event.relatedTarget;
|
|
44
|
+
if (relatedTarget && !containerRef.current?.contains(relatedTarget)) {
|
|
45
|
+
closeAllDialogs();
|
|
46
|
+
}
|
|
47
|
+
}, ...props }));
|
|
3
48
|
}
|
|
4
49
|
|
|
5
|
-
export {
|
|
50
|
+
export { DropdownContainer, DropdownWithPanel };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kth/style",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
},
|
|
24
24
|
"files": [
|
|
25
25
|
"scss",
|
|
26
|
-
"dist"
|
|
26
|
+
"dist",
|
|
27
|
+
"assets"
|
|
27
28
|
],
|
|
28
29
|
"devDependencies": {
|
|
29
30
|
"@rollup/plugin-commonjs": "^24.1.0",
|
|
@@ -47,5 +48,5 @@
|
|
|
47
48
|
"peerDependencies": {
|
|
48
49
|
"react": "*"
|
|
49
50
|
},
|
|
50
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "9eebb100e8d56f87395e62ecc89603c446832f20"
|
|
51
52
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
@use "../tokens/spacing.scss";
|
|
2
|
+
@use "../tokens/icons.scss";
|
|
3
|
+
|
|
4
|
+
/// When true, the file generates CSS code for the entire document
|
|
5
|
+
///
|
|
6
|
+
/// Set to `false` when importing if you want to use the mixin but don't want
|
|
7
|
+
/// to have the "kth-details" class
|
|
8
|
+
$generate-css: true !default;
|
|
9
|
+
$border-width: spacing.$space-4;
|
|
10
|
+
|
|
11
|
+
@mixin details {
|
|
12
|
+
summary {
|
|
13
|
+
color: var(--color-tertiary);
|
|
14
|
+
padding-block: var(--space-inner-block);
|
|
15
|
+
cursor: pointer;
|
|
16
|
+
// padding-inline-start: spacing.$space-20;
|
|
17
|
+
list-style: none;
|
|
18
|
+
font: inherit;
|
|
19
|
+
display: grid;
|
|
20
|
+
grid-template-columns: 1.5rem auto;
|
|
21
|
+
|
|
22
|
+
&::before {
|
|
23
|
+
@include icons.icon-caret-right;
|
|
24
|
+
background-color: var(--color-tertiary);
|
|
25
|
+
margin-block: spacing.$space-2;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
&:hover {
|
|
29
|
+
text-decoration: underline;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&[open] summary::before {
|
|
34
|
+
rotate: 0deg;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
> div {
|
|
38
|
+
border-inline-start: $border-width solid var(--color-tertiary);
|
|
39
|
+
padding-inline-start: spacing.$space-16;
|
|
40
|
+
padding-block: spacing.$space-8;
|
|
41
|
+
margin-inline-start: spacing.$space-8;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@if $generate-css {
|
|
46
|
+
@layer kth-style {
|
|
47
|
+
.kth-details {
|
|
48
|
+
@include details;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -5,12 +5,21 @@
|
|
|
5
5
|
@layer kth-style {
|
|
6
6
|
.kth-header.intranet {
|
|
7
7
|
@include colors.theme-intranet;
|
|
8
|
+
.kth-logotype img.white {
|
|
9
|
+
display: none;
|
|
10
|
+
}
|
|
8
11
|
}
|
|
9
12
|
.kth-header.external {
|
|
10
13
|
@include colors.theme-inverse;
|
|
14
|
+
.kth-logotype img.blue {
|
|
15
|
+
display: none;
|
|
16
|
+
}
|
|
11
17
|
}
|
|
12
18
|
.kth-header.student-web {
|
|
13
19
|
@include colors.theme-student-web;
|
|
20
|
+
.kth-logotype img.white {
|
|
21
|
+
display: none;
|
|
22
|
+
}
|
|
14
23
|
}
|
|
15
24
|
|
|
16
25
|
.kth-header {
|