mirror of
https://github.com/navikt/aksel.git
synced 2026-10-13 01:02:02 +00:00
Compare commits
24
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
42bc4288f5 | ||
|
|
3d7cc1112c | ||
|
|
00fec86f80 | ||
|
|
d631e4b611 | ||
|
|
3097afe082 | ||
|
|
fe22c83bef | ||
|
|
4684d487af | ||
|
|
7485befdfa | ||
|
|
313fd1558a | ||
|
|
e184e872a1 | ||
|
|
65bd0a8be6 | ||
|
|
1eadf5d287 | ||
|
|
541ef45b8e | ||
|
|
709c20ed6d | ||
|
|
6530211445 | ||
|
|
88a665f772 | ||
|
|
dc2b063fda | ||
|
|
1414f85484 | ||
|
|
2fd93bb2be | ||
|
|
1360789bc3 | ||
|
|
cecc905f58 | ||
|
|
1cda942e61 | ||
|
|
ab3a4289ea | ||
|
|
9bafdd3c06 |
No files matched your search
@@ -71,7 +71,7 @@ jobs:
|
||||
- run: git remote set-url origin https://github-actions[bot]:$NAV_DS_TOKEN@github.com/$GITHUB_REPOSITORY.git
|
||||
env:
|
||||
NAV_DS_TOKEN: ${{secrets.GIT_REPO}}
|
||||
- run: yarn lerna version patch --include-merged-tags --no-private --yes
|
||||
- run: yarn lerna version patch --include-merged-tags --yes
|
||||
- run: yarn lerna publish from-package --yes
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTOMATION}}
|
||||
|
||||
@@ -111,3 +111,7 @@ utilities/**/css
|
||||
@navikt/ds-icons/NAV-ikonpakke-svg.zip
|
||||
*/**/NAV-ikonpakke-png.zip
|
||||
*/**/NAV-ikonpakke-svg.zip
|
||||
|
||||
react-docgen.json
|
||||
cjs
|
||||
esm
|
||||
+28
-3
@@ -1,7 +1,32 @@
|
||||
module.exports = {
|
||||
webpackFinal: async (config, { configType }) => {
|
||||
config.devServer = { stats: "errors-only" };
|
||||
return config;
|
||||
},
|
||||
devServer: { stats: "errors-only" },
|
||||
stories: [
|
||||
"../packages/**/*.stories.@(js|jsx|ts|tsx)",
|
||||
"../@navikt/**/*.stories.@(js|jsx|ts|tsx)",
|
||||
"../.storybook/**/*.stories.@(mdx)",
|
||||
"../packages/**/*.stories.@(js|jsx|ts|tsx|mdx)",
|
||||
"../@navikt/**/*.stories.@(js|jsx|ts|tsx|mdx)",
|
||||
],
|
||||
addons: [
|
||||
"@storybook/addon-links",
|
||||
"@storybook/addon-docs",
|
||||
{
|
||||
name: "@storybook/addon-storysource",
|
||||
options: {
|
||||
loaderOptions: {
|
||||
injectStoryParameters: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "@storybook/addon-essentials",
|
||||
options: {
|
||||
actions: false,
|
||||
controls: { hideNoControlsWarning: true },
|
||||
},
|
||||
},
|
||||
"@whitespace/storybook-addon-html",
|
||||
],
|
||||
addons: ["@storybook/addon-links", "@storybook/addon-essentials"],
|
||||
};
|
||||
@@ -0,0 +1,6 @@
|
||||
import { addons } from "@storybook/addons";
|
||||
import NavTheme from "./theme.js";
|
||||
|
||||
addons.setConfig({
|
||||
theme: NavTheme,
|
||||
});
|
||||
@@ -1,14 +1,13 @@
|
||||
import "nav-frontend-core";
|
||||
import "@navikt/ds-css/baseline/index.css";
|
||||
import "@navikt/ds-css/index.css";
|
||||
|
||||
export const parameters = {
|
||||
actions: { argTypesRegex: "^on[A-Z].*" },
|
||||
options: {
|
||||
// Makes sure `all` story is first
|
||||
storySort: (a, b) => {
|
||||
if (a[0].indexOf("all") !== -1) return -1;
|
||||
if (b[0].indexOf("all") !== -1) return 1;
|
||||
return 0;
|
||||
storySort: {
|
||||
method: "",
|
||||
order: [],
|
||||
locales: "",
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
import { Meta } from "@storybook/addon-docs/blocks";
|
||||
|
||||
<Meta title="ds-react/Kom i gang" />
|
||||
|
||||
# Ta i bruk `@navikt/ds-react` pakken
|
||||
|
||||
## Oppsett
|
||||
|
||||
```bash
|
||||
yarn add @navikt/ds-react @navikt/ds-css
|
||||
```
|
||||
|
||||
Siden stilene ikke importeres direkte i komponentene, så må man selv importere ds-css.
|
||||
Dette gjøres for å la komponetene brukes i Nextjs prosjekter.
|
||||
|
||||
```bash
|
||||
import "@navikt/ds-css"
|
||||
```
|
||||
|
||||
Dette vil også legge css-variabler på :root. For å få dette til å fungere med IE11, kan denne pakken tas i bruk: https://jhildenbiddle.github.io/css-vars-ponyfill/#/
|
||||
|
||||
## Testing
|
||||
|
||||
For å støtte testing med eks Jest som ikke tillater ESM moduler, så kan denne configen legges til
|
||||
|
||||
```bash
|
||||
"moduleNameMapper": {
|
||||
"@navikt/ds-react(.*)": "@navikt/ds-react/cjs$1",
|
||||
"@navikt/ds-icons(.*)": "@navikt/ds-icons/cjs$1"
|
||||
}
|
||||
```
|
||||
|
||||
Dette vil remappe komponentene (og ikonpakken) til å bruke CommonJs versjonen for testing
|
||||
@@ -0,0 +1,6 @@
|
||||
import { create } from "@storybook/theming";
|
||||
|
||||
export default create({
|
||||
base: "light",
|
||||
brandTitle: "NAV Designsystem",
|
||||
});
|
||||
@@ -1,11 +1,31 @@
|
||||
const path = require("path");
|
||||
|
||||
module.exports = (baseConfig) => {
|
||||
baseConfig.config.module.rules.push({
|
||||
test: /\.less$/,
|
||||
loaders: ["style-loader", "css-loader", "less-loader"],
|
||||
include: path.resolve(__dirname, "../packages/"),
|
||||
});
|
||||
baseConfig.config.module.rules.push(
|
||||
{
|
||||
test: /\.css$/,
|
||||
use: ["style-loader", "css-loader"],
|
||||
include: [
|
||||
path.resolve(__dirname, "../node_modules/@navikt/ds-css/index.css"),
|
||||
],
|
||||
},
|
||||
{
|
||||
test: /\.less$/,
|
||||
loaders: ["style-loader", "css-loader", "less-loader"],
|
||||
include: path.resolve(__dirname, "../packages/"),
|
||||
}
|
||||
);
|
||||
baseConfig.config.resolve.alias = {
|
||||
...baseConfig.config.resolve?.alias,
|
||||
"./normalize.css": path.resolve(
|
||||
__dirname,
|
||||
"../node_modules/normalize.css/normalize.css"
|
||||
),
|
||||
"./@navikt/ds-tokens": path.resolve(
|
||||
__dirname,
|
||||
"../node_modules/@navikt/ds-tokens/dist/tokens.css"
|
||||
),
|
||||
};
|
||||
|
||||
return baseConfig.config;
|
||||
};
|
||||
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,18 @@
|
||||
@import "@navikt/ds-tokens";
|
||||
@import "normalize.css";
|
||||
@import "Source-Sans-Pro-regular.css";
|
||||
@import "Source-Sans-Pro-italic.css";
|
||||
@import "Source-Sans-Pro-600.css";
|
||||
@import "print.css";
|
||||
@import "utility.css";
|
||||
|
||||
body {
|
||||
font-family: var(--navds-font-family);
|
||||
line-height: 1.375;
|
||||
color: var(--navds-color-text-primary);
|
||||
font-size: 1.125rem;
|
||||
}
|
||||
|
||||
a {
|
||||
color: var(--navds-color-text-link);
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
@import url(~normalize.css);
|
||||
@import url(~@navikt/ds-tokens/dist/tokens.css);
|
||||
@import url(Source-Sans-Pro-regular.css);
|
||||
@import url(Source-Sans-Pro-italic.css);
|
||||
@import url(Source-Sans-Pro-600.css);
|
||||
@import url(print.css);
|
||||
@import url(utility.css);
|
||||
|
||||
body {
|
||||
font-family: var(--navds-font-family);
|
||||
line-height: 1.375;
|
||||
color: var(--navds-color-text-primary);
|
||||
font-size: 1.125rem;
|
||||
}
|
||||
|
||||
a {
|
||||
color: var(--navds-color-text-link);
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
@@ -1,3 +1,23 @@
|
||||
/**************************
|
||||
* .navds-grid *
|
||||
**************************/
|
||||
|
||||
.navds-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(12, minmax(0, 1fr));
|
||||
grid-gap: var(--navds-grid-gutter-small);
|
||||
}
|
||||
|
||||
@media (min-width: 448px) {
|
||||
.navds-grid {
|
||||
grid-gap: var(--navds-grid-gutter-medium-and-larger);
|
||||
}
|
||||
}
|
||||
|
||||
/**************************
|
||||
* .navds-grid__cell *
|
||||
**************************/
|
||||
|
||||
.navds-grid__cell--xs-1 {
|
||||
grid-column: span 1;
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
.navds-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(12, minmax(0, 1fr));
|
||||
grid-gap: var(--navds-grid-gutter-small);
|
||||
}
|
||||
|
||||
@media (min-width: 448px) {
|
||||
.navds-grid {
|
||||
grid-gap: var(--navds-grid-gutter-medium-and-larger);
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
@import "./grid.css";
|
||||
@import "./cell.css";
|
||||
@@ -0,0 +1,13 @@
|
||||
@import "baseline/baseline.css";
|
||||
@import "accordion.css";
|
||||
@import "alert.css";
|
||||
@import "button.css";
|
||||
@import "content-container.css";
|
||||
@import "grid.css";
|
||||
@import "internal-header.css";
|
||||
@import "layout.css";
|
||||
@import "link.css";
|
||||
@import "modal.css";
|
||||
@import "popover.css";
|
||||
@import "tag.css";
|
||||
@import "typography.css";
|
||||
@@ -0,0 +1,72 @@
|
||||
/**************************
|
||||
* .navds-header *
|
||||
**************************/
|
||||
|
||||
.navds-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: var(--navds-color-darkgray);
|
||||
color: white;
|
||||
max-width: 100vw;
|
||||
min-height: 50px;
|
||||
}
|
||||
|
||||
.navds-header__column {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
/**************************
|
||||
* .navds-header__title *
|
||||
**************************/
|
||||
|
||||
.navds-header__title {
|
||||
padding: 0 1.5rem 0 1.5rem;
|
||||
border-right: 1px solid var(--navds-color-gray-40);
|
||||
display: flex;
|
||||
align-self: stretch;
|
||||
align-items: center;
|
||||
text-decoration: none;
|
||||
margin: 0;
|
||||
color: var(--navds-color-text-inverse);
|
||||
font-size: var(--navds-font-size-medium);
|
||||
font-weight: var(--navds-font-weight-bold);
|
||||
line-height: var(--navds-font-line-height-medium);
|
||||
}
|
||||
|
||||
.navds-header__title > span > a {
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.navds-header__title > span > a:focus {
|
||||
box-shadow: var(--navds-shadow-focus-on-dark);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
/**************************
|
||||
* .navds-header__user *
|
||||
**************************/
|
||||
|
||||
.navds-header__user {
|
||||
color: var(--navds-color-text-inverse);
|
||||
padding: 0 1.5rem 0 1.5rem;
|
||||
margin-left: auto;
|
||||
border-left: 1px solid var(--navds-color-gray-40);
|
||||
display: flex;
|
||||
align-self: stretch;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.navds-header__name {
|
||||
margin-right: 1rem;
|
||||
font-size: var(--navds-font-size-small);
|
||||
font-weight: var(--navds-font-weight-bold);
|
||||
line-height: var(--navds-font-line-height-small);
|
||||
}
|
||||
|
||||
.navds-header__ident {
|
||||
font-size: var(--navds-font-size-xs);
|
||||
font-weight: var(--navds-font-weight-bold);
|
||||
line-height: var(--navds-font-line-height-xs);
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
@import "./title.css";
|
||||
@import "./user.css";
|
||||
|
||||
.navds-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: var(--navds-color-darkgray);
|
||||
color: white;
|
||||
max-width: 100vw;
|
||||
min-height: 50px;
|
||||
}
|
||||
|
||||
.navds-header__column {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
.navds-header__title {
|
||||
padding: 0 1.5rem 0 1.5rem;
|
||||
border-right: 1px solid var(--navds-color-gray-40);
|
||||
display: flex;
|
||||
align-self: stretch;
|
||||
align-items: center;
|
||||
text-decoration: none;
|
||||
margin: 0;
|
||||
color: var(--navds-color-text-inverse);
|
||||
font-size: var(--navds-font-size-medium);
|
||||
font-weight: var(--navds-font-weight-bold);
|
||||
line-height: var(--navds-font-line-height-medium);
|
||||
}
|
||||
|
||||
.navds-header__title > span > a {
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.navds-header__title > span > a:focus {
|
||||
box-shadow: var(--navds-shadow-focus-on-dark);
|
||||
outline: none;
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
.navds-header__user {
|
||||
color: var(--navds-color-text-inverse);
|
||||
padding: 0 1.5rem 0 1.5rem;
|
||||
margin-left: auto;
|
||||
border-left: 1px solid var(--navds-color-gray-40);
|
||||
display: flex;
|
||||
align-self: stretch;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.navds-header__name {
|
||||
margin-right: 1rem;
|
||||
font-size: var(--navds-font-size-small);
|
||||
font-weight: var(--navds-font-weight-bold);
|
||||
line-height: var(--navds-font-line-height-small);
|
||||
}
|
||||
|
||||
.navds-header__ident {
|
||||
font-size: var(--navds-font-size-xs);
|
||||
font-weight: var(--navds-font-weight-bold);
|
||||
line-height: var(--navds-font-line-height-xs);
|
||||
}
|
||||
File renamed without changes.
@@ -1 +0,0 @@
|
||||
@import "./layout.css";
|
||||
File renamed without changes.
File renamed without changes.
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@navikt/ds-css",
|
||||
"version": "0.1.17",
|
||||
"version": "0.2.1",
|
||||
"private": false,
|
||||
"description": "Css for NAV Designsystem components",
|
||||
"author": "NAV Designsystem team",
|
||||
@@ -15,8 +15,16 @@
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/navikt/nav-frontend-moduler.git"
|
||||
},
|
||||
"dependencies": {
|
||||
"main": "./dist/index.css",
|
||||
"scripts": {
|
||||
"build": "postcss --use postcss-import -o dist/index.css index.css",
|
||||
"watch-css": "postcss -w --use postcss-import -o dist/index.css index.css"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@navikt/ds-tokens": "^0.1.0",
|
||||
"normalize.css": "^8.0.1"
|
||||
"normalize.css": "^8.0.1",
|
||||
"postcss": "^8.2.7",
|
||||
"postcss-cli": "^8.3.1",
|
||||
"postcss-import": "^14.0.0"
|
||||
}
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"type": "commonjs",
|
||||
"main": "index.js",
|
||||
"typings": "../esm/index.d.ts",
|
||||
"sideEffects": false
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
// https://levelup.gitconnected.com/learn-svg-to-react-using-figma-api-be0a5f9c0ca
|
||||
// used for reference/implementation
|
||||
|
||||
const api = require("axios");
|
||||
import { create, get } from "axios";
|
||||
|
||||
// Requires user to add a personalized figma token in .env
|
||||
const headers = {
|
||||
@@ -11,7 +11,7 @@ const headers = {
|
||||
* Api connection for icon components
|
||||
* https://www.figma.com/file/UmEVH3pZ71uJPsSz9ilP3Y/NAV-ikoner-2.1-Figma-i-test?node-id=0%3A1
|
||||
*/
|
||||
const instanceFiles = api.create({
|
||||
const instanceFiles = create({
|
||||
baseURL: `https://api.figma.com/v1/files/${process.env.FILE_KEY}/components`,
|
||||
headers,
|
||||
});
|
||||
@@ -19,7 +19,7 @@ const instanceFiles = api.create({
|
||||
/**
|
||||
* api endpoint for images
|
||||
*/
|
||||
const instanceImages = api.create({
|
||||
const instanceImages = create({
|
||||
baseURL: `https://api.figma.com/v1/images/${process.env.FILE_KEY}`,
|
||||
headers,
|
||||
});
|
||||
@@ -45,9 +45,9 @@ const getSvgImageUrls = async (nodeIds) => {
|
||||
/**
|
||||
* Gets raw svg data from url
|
||||
*/
|
||||
const getIconContent = async (url) => api.get(url);
|
||||
const getIconContent = async (url) => get(url);
|
||||
|
||||
module.exports = {
|
||||
export default {
|
||||
getNodeChildren,
|
||||
getSvgImageUrls,
|
||||
getIconContent,
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
const api = require("./api");
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const pLimit = require("p-limit");
|
||||
const rimraf = require("rimraf");
|
||||
const startCase = require("lodash.startcase");
|
||||
import { getNodeChildren, getSvgImageUrls, getIconContent } from "./api";
|
||||
import { existsSync, unlinkSync, writeFileSync, mkdirSync } from "fs";
|
||||
import { resolve } from "path";
|
||||
import pLimit from "p-limit";
|
||||
import rimraf from "rimraf";
|
||||
import startCase from "lodash.startcase";
|
||||
|
||||
const generateMetadata = (iconNodesArr) => {
|
||||
return iconNodesArr
|
||||
@@ -32,14 +32,14 @@ const main = async () => {
|
||||
// Limiting to ~20 concurrent downloads seems to lead to fewer erros
|
||||
const limit = pLimit(20);
|
||||
|
||||
const iconNodesArr = await api.getNodeChildren().catch((e) => {
|
||||
const iconNodesArr = await getNodeChildren().catch((e) => {
|
||||
throw e;
|
||||
});
|
||||
|
||||
if (fs.existsSync(metadataFileName)) {
|
||||
fs.unlinkSync(metadataFileName);
|
||||
if (existsSync(metadataFileName)) {
|
||||
unlinkSync(metadataFileName);
|
||||
}
|
||||
fs.writeFileSync(
|
||||
writeFileSync(
|
||||
metadataFileName,
|
||||
JSON.stringify(generateMetadata(iconNodesArr), null, 4),
|
||||
{
|
||||
@@ -47,25 +47,24 @@ const main = async () => {
|
||||
}
|
||||
);
|
||||
|
||||
const iconUrls = await api.getSvgImageUrls(
|
||||
const iconUrls = await getSvgImageUrls(
|
||||
iconNodesArr.map((node) => node.node_id).join(",")
|
||||
);
|
||||
|
||||
if (fs.existsSync(iconFolder)) {
|
||||
if (existsSync(iconFolder)) {
|
||||
rimraf.sync(iconFolder);
|
||||
}
|
||||
fs.mkdirSync(iconFolder);
|
||||
mkdirSync(iconFolder);
|
||||
|
||||
console.log("Total icons: " + iconNodesArr.length);
|
||||
|
||||
await Promise.all(
|
||||
iconUrls.map((url, x) =>
|
||||
limit(() =>
|
||||
api
|
||||
.getIconContent(url)
|
||||
getIconContent(url)
|
||||
.then(({ data }) => {
|
||||
fs.writeFileSync(
|
||||
path.resolve(
|
||||
writeFileSync(
|
||||
resolve(
|
||||
iconFolder,
|
||||
`${startCase(iconNodesArr[x].name).replace(/\s/g, "")}.svg`
|
||||
),
|
||||
@@ -86,8 +85,8 @@ const main = async () => {
|
||||
);
|
||||
|
||||
if (misses.length > 0) {
|
||||
fs.writeFileSync(
|
||||
path.resolve("./", `misses.txt`),
|
||||
writeFileSync(
|
||||
resolve("./", `misses.txt`),
|
||||
JSON.stringify(misses, null, 4),
|
||||
{
|
||||
encoding: "utf8",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const fs = require("fs");
|
||||
const sharp = require("sharp");
|
||||
const rimraf = require("rimraf");
|
||||
const pLimit = require("p-limit");
|
||||
import { existsSync, mkdirSync, readdirSync } from "fs";
|
||||
import sharp from "sharp";
|
||||
import rimraf from "rimraf";
|
||||
import pLimit from "p-limit";
|
||||
|
||||
const convertToPng = async () => {
|
||||
const inputDir = "./svg/";
|
||||
@@ -11,14 +11,14 @@ const convertToPng = async () => {
|
||||
|
||||
const limit = pLimit(20);
|
||||
|
||||
if (fs.existsSync(outDir)) {
|
||||
if (existsSync(outDir)) {
|
||||
rimraf.sync(outDir);
|
||||
}
|
||||
fs.mkdirSync(outDir);
|
||||
sizes.forEach((size) => fs.mkdirSync(outDir + size.toString()));
|
||||
mkdirSync(outDir);
|
||||
sizes.forEach((size) => mkdirSync(outDir + size.toString()));
|
||||
|
||||
await Promise.all(
|
||||
fs.readdirSync(inputDir).map((file) => {
|
||||
readdirSync(inputDir).map((file) => {
|
||||
return limit(() =>
|
||||
sizes.forEach((size) => {
|
||||
const density = (100 * size) / 16;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const zipdir = require("zip-dir");
|
||||
import zipdir from "zip-dir";
|
||||
|
||||
const zipDir = async (dir, name) => {
|
||||
await zipdir(dir, { saveTo: name }, function (err, buffer) {
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
{
|
||||
"name": "@navikt/ds-icons",
|
||||
"version": "0.1.7",
|
||||
"version": "0.2.0",
|
||||
"private": false,
|
||||
"description": "NAVs egne ikoner i SVG og React format",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/navikt/nav-frontend-moduler/tree/master/%40navikt/ds-icons"
|
||||
},
|
||||
"keywords": [
|
||||
"NAV",
|
||||
"designsystem",
|
||||
@@ -10,29 +14,30 @@
|
||||
],
|
||||
"license": "MIT",
|
||||
"author": "NAV",
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
"main": "esm/index.js",
|
||||
"module": "esm/index.js",
|
||||
"typings": "esm/index.d.ts",
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"files": [
|
||||
"/lib",
|
||||
"/src",
|
||||
"/cjs",
|
||||
"/esm",
|
||||
"/svg"
|
||||
],
|
||||
"scripts": {
|
||||
"cjs-package": "copyfiles -f config/package.json cjs",
|
||||
"dl-icons": "FILE_KEY=UmEVH3pZ71uJPsSz9ilP3Y node -r dotenv/config figma-api/index.js dotenv_config_path=figma-api/.env",
|
||||
"create-icons": "svgr --silent --typescript --ref --icon --title-prop --replace-attr-values \"#3E3832=currentColor\" -d src svg",
|
||||
"convert-icons": "node figma-api/pngConverter.js",
|
||||
"clean": "rm -rf src && rm -rf lib && rm -rf png && rm -rf NAV-ikonpakke-png.zip && rm -rf NAV-ikonpakke-svg.zip",
|
||||
"build": "npm run clean && npm run create-icons && tsc && npm run convert-icons && node figma-api/zipIcons.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/navikt/nav-frontend-moduler/tree/master/%40navikt/ds-icons"
|
||||
"clean": "rm -rf src && rm -rf esm && rm -rf cjs && rm -rf png && rm -rf NAV-ikonpakke-png.zip && rm -rf NAV-ikonpakke-svg.zip",
|
||||
"build": "npm run clean && npm run create-icons && tsc && tsc -p tsconfig-esm.json && yarn cjs-package && npm run convert-icons && node figma-api/zipIcons.js"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^16.8.0 || ^17.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@svgr/cli": "^5.4.0",
|
||||
"copyfiles": "^2.4.1",
|
||||
"dotenv": "^8.2.0",
|
||||
"lodash.kebabcase": "^4.1.1",
|
||||
"lodash.startcase": "4.4.0",
|
||||
@@ -40,6 +45,5 @@
|
||||
"rimraf": "3.0.2",
|
||||
"sharp": "0.27.1",
|
||||
"zip-dir": "^2.0.0"
|
||||
},
|
||||
"sideEffects": false
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
import { Meta } from "@storybook/addon-docs/blocks";
|
||||
|
||||
<Meta title="ds-icons/Kom i gang" />
|
||||
|
||||
# Ta i bruk ikonpakken `@navikt/ds-icons`
|
||||
|
||||
Alle ikoner kan bli funnet her https://design.nav.no/resources/icons
|
||||
|
||||
## Oppsett
|
||||
|
||||
```bash
|
||||
yarn add @navikt/ds-icons
|
||||
```
|
||||
|
||||
```bash
|
||||
Import { Expand } from `@navikt/ds-icons`;
|
||||
|
||||
<Expand
|
||||
aria-label="Åpne meny"
|
||||
role="img"
|
||||
focusable="false"
|
||||
/>
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
For å støtte testing med eks Jest som ikke tillater ESM moduler, så kan denne configen legges til
|
||||
|
||||
```bash
|
||||
"moduleNameMapper": {
|
||||
"@navikt/ds-react(.*)": "@navikt/ds-react/cjs$1",
|
||||
"@navikt/ds-icons(.*)": "@navikt/ds-icons/cjs$1"
|
||||
}
|
||||
```
|
||||
|
||||
Dette vil remappe Ikonpakken (og komponentpakken) til å bruke CommonJs versjonen for testing
|
||||
@@ -1,35 +1,65 @@
|
||||
import React from "react";
|
||||
// also exported from '@storybook/react' if you can deal with breaking changes in 6.1
|
||||
// import { Story, Meta } from '@storybook/react/types-6-0';
|
||||
import { storiesOf } from "@storybook/react";
|
||||
|
||||
import * as Icons from "../src";
|
||||
export default {
|
||||
title: "ds-icons/Ikoner",
|
||||
argTypes: {
|
||||
Icon: {
|
||||
defaultValue: "System",
|
||||
control: {
|
||||
type: "select",
|
||||
options: Object.entries(Icons).map(([Name, _]) => Name),
|
||||
},
|
||||
},
|
||||
color: { control: "color" },
|
||||
},
|
||||
};
|
||||
|
||||
const iconsStories = storiesOf("@navikt/icons", module);
|
||||
if (process.env.STORYBOOK_CHROMATIC === "true") {
|
||||
const iconsStories = storiesOf("ds-icons/Ikoner", module);
|
||||
|
||||
Object.entries(Icons).forEach(([name, Icon]) => {
|
||||
iconsStories.add(name, () => (
|
||||
<div>
|
||||
<Icon title="hello, world" />
|
||||
<Icon style={{ height: "2em", width: "2em" }} />
|
||||
<Icon style={{ height: "4em", width: "4em" }} />
|
||||
<Icon style={{ height: "4em", width: "4em", color: "white" }} />
|
||||
<Icon style={{ height: "4em", width: "4em", color: "crimson" }} />
|
||||
<br />
|
||||
<Icon style={{ height: "4em", width: "4em", backgroundColor: "#aaa" }} />
|
||||
<Icon style={{ height: "4em", width: "4em", backgroundColor: "#777" }} />
|
||||
<Icon style={{ height: "4em", width: "4em", backgroundColor: "#333" }} />
|
||||
<Icon style={{ height: "4em", width: "4em", backgroundColor: "#000" }} />
|
||||
<br />
|
||||
<Icon
|
||||
style={{ height: "4em", width: "4em", transform: "rotate(45deg)" }}
|
||||
/>
|
||||
<Icon
|
||||
style={{ height: "4em", width: "4em", transform: "rotate(90deg)" }}
|
||||
/>
|
||||
<Icon
|
||||
style={{ height: "4em", width: "4em", transform: "rotate(180deg)" }}
|
||||
/>
|
||||
</div>
|
||||
));
|
||||
});
|
||||
Object.entries(Icons).forEach(([name, Icon]) => {
|
||||
iconsStories.add(name, () => (
|
||||
<div>
|
||||
<Icon title="hello, world" />
|
||||
<Icon style={{ height: "2em", width: "2em" }} />
|
||||
<Icon style={{ height: "4em", width: "4em" }} />
|
||||
<Icon style={{ height: "4em", width: "4em", color: "white" }} />
|
||||
<Icon style={{ height: "4em", width: "4em", color: "crimson" }} />
|
||||
<br />
|
||||
<Icon
|
||||
style={{ height: "4em", width: "4em", backgroundColor: "#aaa" }}
|
||||
/>
|
||||
<Icon
|
||||
style={{ height: "4em", width: "4em", backgroundColor: "#777" }}
|
||||
/>
|
||||
<Icon
|
||||
style={{ height: "4em", width: "4em", backgroundColor: "#333" }}
|
||||
/>
|
||||
<Icon
|
||||
style={{ height: "4em", width: "4em", backgroundColor: "#000" }}
|
||||
/>
|
||||
<br />
|
||||
<Icon
|
||||
style={{ height: "4em", width: "4em", transform: "rotate(45deg)" }}
|
||||
/>
|
||||
<Icon
|
||||
style={{ height: "4em", width: "4em", transform: "rotate(90deg)" }}
|
||||
/>
|
||||
<Icon
|
||||
style={{ height: "4em", width: "4em", transform: "rotate(180deg)" }}
|
||||
/>
|
||||
</div>
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
const Template = ({ Icon, color, size, ...args }) => {
|
||||
const Iconname = Icons[Icon];
|
||||
return <Iconname style={{ fontSize: size, color }} {...args} />;
|
||||
};
|
||||
export const Ikon = Template.bind({});
|
||||
Ikon.args = {
|
||||
size: "24px",
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"extends": "../../utilities/build/tsconfig-pakker.json",
|
||||
"compilerOptions": {
|
||||
"rootDir": "./src",
|
||||
"esModuleInterop": true,
|
||||
"module": "ES2020",
|
||||
"target": "ES2015",
|
||||
"outDir": "./esm",
|
||||
"sourceMap": true,
|
||||
"declaration": true
|
||||
},
|
||||
"include": ["./src"]
|
||||
}
|
||||
@@ -1,11 +1,13 @@
|
||||
{
|
||||
"extends": "../../utilities/build/tsconfig-pakker.json",
|
||||
"compilerOptions": {
|
||||
"module": "ES6",
|
||||
"outDir": "./lib",
|
||||
"module": "commonjs",
|
||||
"outDir": "./cjs",
|
||||
"target": "es2015",
|
||||
"rootDir": "./src",
|
||||
"esModuleInterop": true,
|
||||
"sourceMap": true
|
||||
"sourceMap": false,
|
||||
"declaration": false
|
||||
},
|
||||
"include": ["./src"]
|
||||
}
|
||||
@@ -1,17 +1,39 @@
|
||||
import React, { forwardRef, useEffect, useRef, useState } from "react";
|
||||
import cl from "classnames";
|
||||
import { UnmountClosed, Collapse } from "react-collapse";
|
||||
|
||||
import { Expand } from "@navikt/ds-icons";
|
||||
import "@navikt/ds-css/accordion/index.css";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
|
||||
export interface AccordionProps
|
||||
extends React.HTMLAttributes<HTMLButtonElement> {
|
||||
/**
|
||||
* Component content
|
||||
*/
|
||||
children: React.ReactNode;
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className?: string;
|
||||
/**
|
||||
* Content on interactive surface of component
|
||||
*/
|
||||
heading: React.ReactNode;
|
||||
/**
|
||||
* Opens component if 'true', closes if 'false'
|
||||
* Using this props removes automatic control of open-state
|
||||
* @default false
|
||||
*/
|
||||
open?: boolean;
|
||||
/**
|
||||
* Callback for when user interacts with component
|
||||
*
|
||||
* @param {object} event
|
||||
*/
|
||||
onClick?: (event: React.MouseEvent<HTMLElement, MouseEvent>) => void;
|
||||
/**
|
||||
* Removes content-element from dom when closed
|
||||
* @default false
|
||||
*/
|
||||
renderContentWhenClosed?: boolean;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import React, { useState } from "react";
|
||||
import { Accordion } from "../index";
|
||||
|
||||
export default {
|
||||
title: "@navikt/accordion",
|
||||
title: "ds-react/accordion",
|
||||
component: Accordion,
|
||||
};
|
||||
|
||||
|
||||
@@ -6,11 +6,24 @@ import {
|
||||
InformationFilled,
|
||||
SuccessFilled,
|
||||
} from "@navikt/ds-icons";
|
||||
import "@navikt/ds-css/alert/index.css";
|
||||
|
||||
export interface AlertProps extends React.HTMLAttributes<HTMLDivElement> {
|
||||
/**
|
||||
* Decides what design the alert will have
|
||||
*/
|
||||
variant: "error" | "warning" | "info" | "success";
|
||||
/**
|
||||
* Component content
|
||||
*/
|
||||
children: React.ReactNode;
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className?: string;
|
||||
/**
|
||||
* Reduces padding on component
|
||||
* @default "medium"
|
||||
*/
|
||||
size?: "medium" | "small";
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import React from "react";
|
||||
import { Alert } from "../index";
|
||||
|
||||
export default {
|
||||
title: "@navikt/alert",
|
||||
title: "ds-react/alert",
|
||||
component: Alert,
|
||||
};
|
||||
|
||||
|
||||
@@ -1,9 +1,24 @@
|
||||
import React, { forwardRef } from "react";
|
||||
import cl from "classnames";
|
||||
import "@navikt/ds-css/button/index.css";
|
||||
|
||||
export interface ButtonProps extends React.HTMLAttributes<HTMLButtonElement> {
|
||||
/**
|
||||
* Component content
|
||||
*/
|
||||
children: React.ReactNode;
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className?: string;
|
||||
/**
|
||||
* Decides component design and interactions
|
||||
* @default "primary"
|
||||
*/
|
||||
variant?: "primary" | "secondary" | "action" | "danger";
|
||||
/**
|
||||
* Reduces internal padding for component
|
||||
* @default "medium"
|
||||
*/
|
||||
size?: "medium" | "small";
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import React from "react";
|
||||
import { Button } from "../index";
|
||||
|
||||
export default {
|
||||
title: "@navikt/button",
|
||||
title: "ds-react/button",
|
||||
component: Button,
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"type": "commonjs",
|
||||
"main": "index.js",
|
||||
"typings": "../esm/index.d.ts",
|
||||
"sideEffects": false
|
||||
}
|
||||
@@ -1,8 +1,17 @@
|
||||
import React, { forwardRef, HTMLAttributes } from "react";
|
||||
import cl from "classnames";
|
||||
import "@navikt/ds-css/content-container/index.css";
|
||||
|
||||
export type ContentContainerProps = HTMLAttributes<HTMLDivElement>;
|
||||
export interface ContentContainerProps extends HTMLAttributes<HTMLDivElement> {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
classNames?: string;
|
||||
/**
|
||||
* Component content
|
||||
*/
|
||||
children: React.ReactNode;
|
||||
}
|
||||
|
||||
const ContentContainer = forwardRef<HTMLDivElement, ContentContainerProps>(
|
||||
({ children, className, ...rest }, ref) => (
|
||||
<div
|
||||
|
||||
@@ -5,7 +5,7 @@ import "./style.css";
|
||||
import { useEffect } from "react";
|
||||
|
||||
export default {
|
||||
title: "@navikt/content-container",
|
||||
title: "ds-react/content-container",
|
||||
component: ContentContainer,
|
||||
decorators: [
|
||||
(Story) => {
|
||||
|
||||
@@ -1,12 +1,31 @@
|
||||
import React, { forwardRef, HTMLAttributes } from "react";
|
||||
import cl from "classnames";
|
||||
import "@navikt/ds-css/grid/index.css";
|
||||
|
||||
type Column = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
|
||||
export interface CellProps extends HTMLAttributes<HTMLDivElement> {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className?: string;
|
||||
/**
|
||||
* Component content
|
||||
*/
|
||||
children?: React.ReactNode;
|
||||
/**
|
||||
* Cell columns on width < 448px
|
||||
*/
|
||||
xs: Column;
|
||||
/**
|
||||
* Cell columns on min-width: 448
|
||||
*/
|
||||
sm?: Column;
|
||||
/**
|
||||
* Cell columns on min-width: 648
|
||||
*/
|
||||
md?: Column;
|
||||
/**
|
||||
* Cell columns on min-width: 960px
|
||||
*/
|
||||
lg?: Column;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,16 @@
|
||||
import React, { forwardRef, HTMLAttributes } from "react";
|
||||
import cl from "classnames";
|
||||
import "@navikt/ds-css/grid/index.css";
|
||||
|
||||
export type GridProps = HTMLAttributes<HTMLDivElement>;
|
||||
export interface GridProps extends HTMLAttributes<HTMLDivElement> {
|
||||
/**
|
||||
* Component content
|
||||
*/
|
||||
children: React.ReactNode;
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className?: string;
|
||||
}
|
||||
const Grid = forwardRef<HTMLDivElement, GridProps>(
|
||||
({ children, className, ...rest }, ref) => (
|
||||
<div ref={ref} className={cl("navds-grid", className)} {...rest}>
|
||||
|
||||
@@ -4,7 +4,7 @@ import { ContentContainer } from "../../index";
|
||||
import "./styles.css";
|
||||
|
||||
export default {
|
||||
title: "@navikt/grid",
|
||||
title: "ds-react/grid",
|
||||
component: { Grid, Cell },
|
||||
parameters: {
|
||||
layout: "fullscreen",
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
import React, { forwardRef, HTMLAttributes } from "react";
|
||||
import cl from "classnames";
|
||||
import "@navikt/ds-css/internal-header/index.css";
|
||||
import "@navikt/ds-css/typography/index.css";
|
||||
|
||||
export interface InternalHeaderProps extends HTMLAttributes<HTMLElement> {
|
||||
/**
|
||||
* Component content
|
||||
*/
|
||||
children?: React.ReactNode;
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className?: string;
|
||||
}
|
||||
|
||||
const InternalHeader = forwardRef<HTMLElement, InternalHeaderProps>(
|
||||
|
||||
@@ -1,10 +1,19 @@
|
||||
import React, { forwardRef, HTMLAttributes, createElement } from "react";
|
||||
import cl from "classnames";
|
||||
import "@navikt/ds-css/internal-header/index.css";
|
||||
import "@navikt/ds-css/typography/index.css";
|
||||
|
||||
export interface InternalHeaderTitleProps extends HTMLAttributes<HTMLElement> {
|
||||
/**
|
||||
* Component content
|
||||
*/
|
||||
children?: React.ReactNode;
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className?: string;
|
||||
/**
|
||||
* Tag this component will use. Usefull for defining a button/link
|
||||
* @default "h1"
|
||||
*/
|
||||
element?: keyof React.ReactHTML;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,19 @@
|
||||
import React, { forwardRef, HTMLAttributes } from "react";
|
||||
import cl from "classnames";
|
||||
import "@navikt/ds-css/internal-header/index.css";
|
||||
import "@navikt/ds-css/typography/index.css";
|
||||
|
||||
export interface InternalHeaderUserProps
|
||||
extends HTMLAttributes<HTMLDivElement> {
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className?: string;
|
||||
/**
|
||||
* user name
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* user ident
|
||||
*/
|
||||
ident: string;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
} from "../index";
|
||||
|
||||
export default {
|
||||
title: "@navikt/internal-header",
|
||||
title: "ds-react/internal-header",
|
||||
component: InternalHeader,
|
||||
};
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import "@navikt/ds-css/layout/index.css";
|
||||
import cl from "classnames";
|
||||
import React, {
|
||||
Children,
|
||||
|
||||
@@ -8,7 +8,7 @@ import { Right } from "./components/sections/Right";
|
||||
import "./components/styles.css";
|
||||
|
||||
export default {
|
||||
title: "@navikt/layout/Article",
|
||||
title: "ds-react/layout/Article",
|
||||
component: { Layout },
|
||||
decorators: [
|
||||
(Story) => {
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
import React, { forwardRef } from "react";
|
||||
import cl from "classnames";
|
||||
import "@navikt/ds-css/link/index.css";
|
||||
|
||||
export interface LinkProps
|
||||
extends React.AnchorHTMLAttributes<HTMLAnchorElement> {
|
||||
/**
|
||||
* Component content
|
||||
*/
|
||||
children: React.ReactNode;
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className?: string;
|
||||
/**
|
||||
* Link anchor should direct to
|
||||
*/
|
||||
|
||||
@@ -2,7 +2,7 @@ import React from "react";
|
||||
import { Link } from "../index";
|
||||
import { Add } from "@navikt/ds-icons";
|
||||
export default {
|
||||
title: "@navikt/link",
|
||||
title: "ds-react/link",
|
||||
component: Link,
|
||||
};
|
||||
|
||||
|
||||
@@ -3,12 +3,8 @@ import cl from "classnames";
|
||||
import ReactModal from "react-modal";
|
||||
import mergeRefs from "react-merge-refs";
|
||||
import { Close } from "@navikt/ds-icons";
|
||||
import "@navikt/ds-css/modal/index.css";
|
||||
import { Button } from "../index";
|
||||
|
||||
// TODO: Has to be documented well that the user has to import react-modal and call
|
||||
// ReactModal.setAppElement("#root")
|
||||
|
||||
export interface ModalProps {
|
||||
/**
|
||||
* Content of modal
|
||||
@@ -28,7 +24,7 @@ export interface ModalProps {
|
||||
*/
|
||||
shouldCloseOnOverlayClick?: boolean;
|
||||
/**
|
||||
* User defined classname for wrapper element
|
||||
* @ignore
|
||||
*/
|
||||
className?: string;
|
||||
/**
|
||||
@@ -37,7 +33,14 @@ export interface ModalProps {
|
||||
contentClassName?: string;
|
||||
}
|
||||
|
||||
const Modal = forwardRef<ReactModal, ModalProps>(
|
||||
type ModalLifecycle = {
|
||||
setAppElement?: (element: any) => void;
|
||||
};
|
||||
|
||||
const Modal: ModalLifecycle &
|
||||
React.ForwardRefExoticComponent<
|
||||
ModalProps & React.RefAttributes<ReactModal>
|
||||
> = forwardRef<ReactModal, ModalProps>(
|
||||
(
|
||||
{
|
||||
children,
|
||||
@@ -90,8 +93,6 @@ const Modal = forwardRef<ReactModal, ModalProps>(
|
||||
}
|
||||
);
|
||||
|
||||
export const setAppElement = (element) => {
|
||||
ReactModal.setAppElement(element);
|
||||
};
|
||||
Modal.setAppElement = (element) => ReactModal.setAppElement(element);
|
||||
|
||||
export default Modal;
|
||||
@@ -1,13 +1,12 @@
|
||||
import React, { useState } from "react";
|
||||
import { Modal } from "../index";
|
||||
import ReactModal from "react-modal";
|
||||
|
||||
export default {
|
||||
title: "@navikt/modal",
|
||||
title: "ds-react/modal",
|
||||
component: Modal,
|
||||
};
|
||||
|
||||
ReactModal.setAppElement("#root");
|
||||
Modal.setAppElement("#root");
|
||||
|
||||
export const All = () => {
|
||||
const [open, setOpen] = useState(true);
|
||||
|
||||
@@ -1,34 +1,38 @@
|
||||
{
|
||||
"name": "@navikt/ds-react",
|
||||
"version": "0.1.2",
|
||||
"version": "0.2.3",
|
||||
"private": false,
|
||||
"description": "NAV designsystem react components",
|
||||
"author": "NAV Designsystem team",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"react",
|
||||
"typescript",
|
||||
"javascript"
|
||||
],
|
||||
"main": "lib/index.js",
|
||||
"types": "lib/index.d.ts",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/navikt/nav-frontend-moduler/tree/master/%40navikt/ds-react"
|
||||
},
|
||||
"main": "esm/index.js",
|
||||
"module": "esm/index.js",
|
||||
"typings": "esm/index.d.ts",
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"files": [
|
||||
"/lib"
|
||||
"/cjs",
|
||||
"/esm"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/navikt/nav-frontend-moduler.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsc -p tsconfig.json",
|
||||
"cjs-package": "copyfiles -f config/package.json cjs",
|
||||
"build": "tsc -p tsconfig.json && tsc -p tsconfig-esm.json && yarn cjs-package",
|
||||
"watch": "tsc --watch -p tsconfig.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"@navikt/ds-css": "^0.1.17",
|
||||
"@navikt/ds-icons": "^0.1.7",
|
||||
"@navikt/ds-icons": "^0.2.0",
|
||||
"@popperjs/core": "^2.5.4",
|
||||
"classnames": "^2.2.6",
|
||||
"react-collapse": "^5.1.0",
|
||||
@@ -38,6 +42,7 @@
|
||||
"uuid": "^8.3.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"copyfiles": "^2.4.1",
|
||||
"react-router-dom": "^5.2.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
|
||||
@@ -9,7 +9,6 @@ import { usePopper } from "react-popper";
|
||||
import { Placement } from "@popperjs/core";
|
||||
import mergeRefs from "react-merge-refs";
|
||||
import cl from "classnames";
|
||||
import "@navikt/ds-css/popover/index.css";
|
||||
|
||||
export interface PopoverProps extends HTMLAttributes<HTMLDivElement> {
|
||||
/**
|
||||
@@ -28,11 +27,19 @@ export interface PopoverProps extends HTMLAttributes<HTMLDivElement> {
|
||||
* Content rendered inside popover
|
||||
*/
|
||||
children: React.ReactNode;
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className?: string;
|
||||
/**
|
||||
* Orientation for popover
|
||||
* @default 'auto'
|
||||
* @default "right"
|
||||
*/
|
||||
placement?: Placement;
|
||||
/**
|
||||
* Small reduces padding on popover content
|
||||
* @default "medium"
|
||||
*/
|
||||
size?: "medium" | "small";
|
||||
}
|
||||
|
||||
@@ -67,9 +74,16 @@ const Popover = forwardRef<HTMLDivElement, PopoverProps>(
|
||||
useEventLister(
|
||||
"click",
|
||||
useCallback(
|
||||
(e: MouseEvent) =>
|
||||
!popoverRef.current?.contains(e.target as Node) && close(),
|
||||
[close]
|
||||
(e: MouseEvent) => {
|
||||
if (
|
||||
![anchorEl, popoverRef.current].some((element) =>
|
||||
element?.contains(e.target as Node)
|
||||
)
|
||||
) {
|
||||
close();
|
||||
}
|
||||
},
|
||||
[anchorEl, close]
|
||||
)
|
||||
);
|
||||
|
||||
@@ -125,7 +139,7 @@ const Popover = forwardRef<HTMLDivElement, PopoverProps>(
|
||||
<div
|
||||
ref={mergedRef}
|
||||
className={cl("navds-popover", `navds-popover--${size}`, className, {
|
||||
"popover--hidden": !open || !anchorEl,
|
||||
"navds-popover--hidden": !open || !anchorEl,
|
||||
})}
|
||||
aria-live="polite"
|
||||
aria-hidden={!open || !anchorEl}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Popover } from "../index";
|
||||
import { Meta } from "@storybook/react/types-6-0";
|
||||
import { placements } from "@popperjs/core";
|
||||
export default {
|
||||
title: "@navikt/popover",
|
||||
title: "ds-react/popover",
|
||||
component: Popover,
|
||||
parameters: {
|
||||
chromatic: { disable: true },
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
import React, { forwardRef, HTMLAttributes } from "react";
|
||||
import cl from "classnames";
|
||||
import "@navikt/ds-css/tag/index.css";
|
||||
|
||||
export interface TagProps extends HTMLAttributes<HTMLSpanElement> {
|
||||
/**
|
||||
* Component content
|
||||
*/
|
||||
children: React.ReactNode;
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
className?: string;
|
||||
/**
|
||||
* Changes background-color and border-color
|
||||
*/
|
||||
@@ -11,11 +17,12 @@ export interface TagProps extends HTMLAttributes<HTMLSpanElement> {
|
||||
}
|
||||
|
||||
const Tag = forwardRef<HTMLSpanElement, TagProps>(
|
||||
({ children, className, variant }, ref) => {
|
||||
({ children, className, variant, ...rest }, ref) => {
|
||||
return (
|
||||
<span
|
||||
ref={ref}
|
||||
className={cl("navds-tag", className, `navds-tag--${variant}`)}
|
||||
{...rest}
|
||||
>
|
||||
{children}
|
||||
</span>
|
||||
|
||||
@@ -2,7 +2,7 @@ import React from "react";
|
||||
import { Tag } from "../index";
|
||||
import { Meta } from "@storybook/react/types-6-0";
|
||||
export default {
|
||||
title: "@navikt/tag",
|
||||
title: "ds-react/tag",
|
||||
component: Tag,
|
||||
} as Meta;
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"extends": "../../utilities/build/tsconfig-pakker.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "./esm",
|
||||
"rootDir": "./",
|
||||
"esModuleInterop": true,
|
||||
"module": "ES2020",
|
||||
"target": "ES2015",
|
||||
"sourceMap": true,
|
||||
"declaration": true
|
||||
},
|
||||
"include": ["./*"]
|
||||
}
|
||||
@@ -1,10 +1,13 @@
|
||||
{
|
||||
"extends": "../../utilities/build/tsconfig-pakker.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "./lib",
|
||||
"outDir": "./cjs",
|
||||
"rootDir": "./",
|
||||
"esModuleInterop": true,
|
||||
"sourceMap": true
|
||||
"module": "commonjs",
|
||||
"target": "es2015",
|
||||
"sourceMap": false,
|
||||
"declaration": false
|
||||
},
|
||||
"include": ["./*"]
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
import "@navikt/ds-css/typography/index.css";
|
||||
|
||||
export { default as Heading } from "./Heading";
|
||||
export * from "./Heading";
|
||||
export { default as Text } from "./Text";
|
||||
|
||||
@@ -2,7 +2,7 @@ import React from "react";
|
||||
import { Heading, Text, Paragraph, Lead } from "../index";
|
||||
|
||||
export default {
|
||||
title: "@navikt/typography",
|
||||
title: "ds-react/typography",
|
||||
component: Heading,
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,16 @@
|
||||
# Endringslogg
|
||||
|
||||
## 10. Mars 2021
|
||||
|
||||
### Oppdatert feil-styling og state-handling for skjemakomponenter
|
||||
|
||||
[#1018](https://github.com/navikt/nav-frontend-moduler/pull/1018)
|
||||
|
||||
- Feil på Skjemagruppe vil føre til feil-styling på checkbox/radio og checkboxpanel/radiopanel
|
||||
- Checkboxpanel, Radiopanel og Radio har nå feil-prop
|
||||
- Feil + disabled styling er satt til bare disabled nå.
|
||||
- checkbox/radio og checkboxpanel/radiopanel kan nå alle ta i bruk utenFeilPropagerings-prop
|
||||
|
||||
## 01. Mars 2021
|
||||
|
||||
### Nav-frontend-typografi-style støtter nå Less v4
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
/.pnp
|
||||
.pnp.js
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# next.js
|
||||
/.next/
|
||||
/out/
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
*.pem
|
||||
|
||||
# debug
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
# local env files
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
# vercel
|
||||
.vercel
|
||||
@@ -0,0 +1,48 @@
|
||||
# Nytt oppsett for design.nav.no
|
||||
|
||||
Planener er at nytt design og innhold for design.nav.no vil bli utviklet her med hjelp av nextjs.
|
||||
|
||||
## Kom i gang
|
||||
|
||||
> Note: Kjøres fra root, ikke docs/package.json
|
||||
|
||||
- `yarn install`
|
||||
- `yarn boot`
|
||||
- `yarn next-dev`
|
||||
|
||||
## Nextjs default Readme
|
||||
|
||||
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
|
||||
|
||||
## Getting Started
|
||||
|
||||
First, run the development server:
|
||||
|
||||
```bash
|
||||
npm run dev
|
||||
# or
|
||||
yarn dev
|
||||
```
|
||||
|
||||
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
|
||||
|
||||
You can start editing the page by modifying `pages/index.js`. The page auto-updates as you edit the file.
|
||||
|
||||
[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.js`.
|
||||
|
||||
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.
|
||||
|
||||
## Learn More
|
||||
|
||||
To learn more about Next.js, take a look at the following resources:
|
||||
|
||||
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
|
||||
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
|
||||
|
||||
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
|
||||
|
||||
## Deploy on Vercel
|
||||
|
||||
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
|
||||
|
||||
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
|
||||
@@ -0,0 +1,6 @@
|
||||
<svg width="77" height="48" viewBox="0 0 77 48" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 34.4688L4.90367 22.3328H9.61534L4.71792 34.4688H0Z" fill="white"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M60.5095 34.4688L65.3504 22.3328H67.9191L63.0785 34.4688H60.5095Z" fill="white"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M70.0298 34.4688L74.8699 22.3328H76.2341L71.3934 34.4688H70.0298Z" fill="white"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M56.055 22.3327H51.7901C51.7901 22.3327 51.4962 22.3327 51.3922 22.5923L49.032 29.8176L46.6737 22.5923C46.5698 22.3327 46.2741 22.3327 46.2741 22.3327H38.0738C37.8963 22.3327 37.7474 22.481 37.7474 22.6574V25.1111C37.7474 23.1647 35.6763 22.3327 34.4635 22.3327C31.7477 22.3327 29.9297 24.1215 29.3636 26.8411C29.3329 25.0369 29.183 24.3905 28.697 23.7284C28.4738 23.4041 28.1511 23.1314 27.7998 22.9059C27.0764 22.4821 26.4268 22.3327 25.0308 22.3327H23.3917C23.3917 22.3327 23.0955 22.3327 22.991 22.5923L21.4996 26.2883V22.6574C21.4996 22.481 21.3519 22.3327 21.1747 22.3327H17.3818C17.3818 22.3327 17.089 22.3327 16.9825 22.5923L15.432 26.4355C15.432 26.4355 15.2772 26.8198 15.6311 26.8198H17.089V34.143C17.089 34.3248 17.2321 34.4688 17.4147 34.4688H21.1747C21.3519 34.4688 21.4996 34.3248 21.4996 34.143V26.8198H22.9651C23.8061 26.8198 23.9842 26.8428 24.3114 26.9953C24.5085 27.0697 24.686 27.2202 24.7829 27.3938C24.9811 27.767 25.0308 28.2152 25.0308 29.5367V34.143C25.0308 34.3248 25.1768 34.4688 25.3572 34.4688H28.9609C28.9609 34.4688 29.3682 34.4688 29.5292 34.0666L30.3279 32.0927C31.3898 33.5801 33.1377 34.4688 35.3099 34.4688H35.7845C35.7845 34.4688 36.1944 34.4688 36.3566 34.0666L37.7474 30.622V34.143C37.7474 34.3248 37.8963 34.4688 38.0738 34.4688H41.7524C41.7524 34.4688 42.1583 34.4688 42.3213 34.0666C42.3213 34.0666 43.7926 30.4138 43.7983 30.3862H43.8005C43.8571 30.0823 43.4731 30.0823 43.4731 30.0823H42.16V23.8145L46.2911 34.0666C46.4525 34.4688 46.8592 34.4688 46.8592 34.4688H51.205C51.205 34.4688 51.614 34.4688 51.7754 34.0666L56.3552 22.7258C56.5137 22.3327 56.055 22.3327 56.055 22.3327V22.3327ZM37.7474 30.0823H35.2764C34.2928 30.0823 33.4927 29.2859 33.4927 28.3012C33.4927 27.3182 34.2928 26.5167 35.2764 26.5167H35.9674C36.9485 26.5167 37.7474 27.3182 37.7474 28.3012V30.0823ZM35.5908 47.9835C22.3436 47.9835 11.6021 37.2426 11.6021 23.9935C11.6021 10.7429 22.3436 0 35.5908 0C48.8427 0 59.5854 10.7429 59.5854 23.9935C59.5854 37.2426 48.8427 47.9835 35.5908 47.9835Z" fill="white"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.5 KiB |
@@ -0,0 +1,61 @@
|
||||
import React, { useState } from "react";
|
||||
import Tabs from "../tabs/Tabs";
|
||||
import style from "./preview.module.css";
|
||||
import { renderToString } from "react-dom/server";
|
||||
import Bash from "../code/Bash";
|
||||
import Prettier from "prettier/standalone";
|
||||
import ParserBabel from "prettier/parser-babel";
|
||||
|
||||
const prettierOptions = {
|
||||
semi: true,
|
||||
parser: "babel",
|
||||
plugins: [ParserBabel],
|
||||
jsxBracketSameLine: false,
|
||||
printWidth: 30,
|
||||
};
|
||||
|
||||
interface PreviewProps {
|
||||
react: string;
|
||||
children?: React.ReactElement;
|
||||
hideHtml?: boolean;
|
||||
}
|
||||
|
||||
const Preview = ({
|
||||
children,
|
||||
react,
|
||||
hideHtml = false,
|
||||
...props
|
||||
}: PreviewProps) => {
|
||||
const [tab, setTab] = useState(0);
|
||||
const handleChange = (x: number) => {
|
||||
setTab(x);
|
||||
};
|
||||
|
||||
const reactFormat = Prettier.format(react, prettierOptions).slice(0, -2);
|
||||
const htmlFormat =
|
||||
!!children &&
|
||||
Prettier.format(
|
||||
renderToString(
|
||||
React.Children.count(children) > 1 ? <div>{children}</div> : children
|
||||
),
|
||||
prettierOptions
|
||||
)
|
||||
.slice(0, -2)
|
||||
.replace(` data-reactroot=""`, "");
|
||||
|
||||
const tabs = !hideHtml || !!children ? ["REACT", "HTML/CSS"] : ["REACT"];
|
||||
|
||||
return (
|
||||
<div className={style.wrapper}>
|
||||
{!!children && <div className={style.preview}>{children}</div>}
|
||||
<Tabs tabs={tabs} onChange={(x) => handleChange(x)} />
|
||||
{tab === 0 && <Bash code={reactFormat} language="jsx" copy />}
|
||||
|
||||
{(!hideHtml || !!children) && tab === 1 && (
|
||||
<Bash code={htmlFormat} language="jsx" copy />
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Preview;
|
||||
@@ -0,0 +1,13 @@
|
||||
.wrapper {
|
||||
padding: 1rem;
|
||||
margin: 1rem 0;
|
||||
background-color: var(--bg-secondary);
|
||||
margin-bottom: 3rem;
|
||||
outline: var(--outline);
|
||||
}
|
||||
|
||||
.preview {
|
||||
border-bottom: 2px solid var(--code-divider);
|
||||
padding-bottom: 3rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
import copy from "copy-to-clipboard";
|
||||
import Prism from "prismjs";
|
||||
import style from "./bash.module.css";
|
||||
import cl from "classnames";
|
||||
import { Files } from "@navikt/ds-icons";
|
||||
import { Popover } from "@navikt/ds-react";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import "prismjs/components/prism-jsx.min";
|
||||
|
||||
type PrismLanguages =
|
||||
| "extend"
|
||||
| "insertBefore"
|
||||
| "DFS"
|
||||
| "markup"
|
||||
| "html"
|
||||
| "mathml"
|
||||
| "svg"
|
||||
| "xml"
|
||||
| "ssml"
|
||||
| "atom"
|
||||
| "rss"
|
||||
| "css"
|
||||
| "clike"
|
||||
| "javascript"
|
||||
| "js"
|
||||
| "jsx";
|
||||
|
||||
export const copyCode = (content) => {
|
||||
if (typeof content === "string") {
|
||||
copy(content, {
|
||||
format: "text/plain",
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const Bash = ({
|
||||
code,
|
||||
terminal = false,
|
||||
copy = false,
|
||||
language = "html",
|
||||
...props
|
||||
}: {
|
||||
code: string;
|
||||
terminal?: boolean;
|
||||
copy?: boolean;
|
||||
language?: PrismLanguages;
|
||||
}) => {
|
||||
const highlighted = terminal
|
||||
? code
|
||||
: Prism.highlight(code, Prism.languages[language], language);
|
||||
|
||||
const buttonRef = useRef<HTMLButtonElement>(null);
|
||||
const timeoutRef = useRef<NodeJS.Timeout>();
|
||||
const [openPopover, setOpenPopover] = useState<boolean>(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (openPopover) {
|
||||
timeoutRef.current = setTimeout(() => setOpenPopover(false), 1500);
|
||||
return () => timeoutRef.current && clearTimeout(timeoutRef.current);
|
||||
}
|
||||
}, [openPopover]);
|
||||
|
||||
const handleCopy = () => {
|
||||
copyCode(code);
|
||||
setOpenPopover(true);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={style.preWrapper}>
|
||||
<pre className={style.pre}>
|
||||
<code
|
||||
className={cl(style.code, {
|
||||
[style.codeCopy]: copy,
|
||||
[style.terminal]: terminal,
|
||||
})}
|
||||
{...props}
|
||||
dangerouslySetInnerHTML={{ __html: highlighted }}
|
||||
/>
|
||||
{copy && (
|
||||
<>
|
||||
<div className={style.buttonBackground}>
|
||||
<button
|
||||
ref={buttonRef}
|
||||
className={style.copyButton}
|
||||
onClick={() => handleCopy()}
|
||||
>
|
||||
<Files />
|
||||
</button>
|
||||
<Popover
|
||||
role="alert"
|
||||
anchorEl={buttonRef.current}
|
||||
open={openPopover}
|
||||
onClose={() => setOpenPopover(false)}
|
||||
size="small"
|
||||
placement="auto-start"
|
||||
/* arrow={false} */
|
||||
>
|
||||
Kode er kopiert
|
||||
</Popover>
|
||||
)
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</pre>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Bash;
|
||||
@@ -0,0 +1,22 @@
|
||||
import Bash from "./Bash";
|
||||
|
||||
interface ImportProps {
|
||||
from: string;
|
||||
imports: string | string[];
|
||||
namedExport?: boolean;
|
||||
}
|
||||
|
||||
const Import = ({ namedExport = true, from, imports }: ImportProps) => {
|
||||
const genCode = () => {
|
||||
if (Array.isArray(imports)) {
|
||||
return `import { ${imports.join(", ")} } from "${from}";`;
|
||||
} else if (!namedExport) {
|
||||
return `import ${imports} from "${from}";`;
|
||||
} else {
|
||||
return `import { ${imports} } from "${from}";`;
|
||||
}
|
||||
};
|
||||
return <Bash code={genCode()} copy language="jsx"></Bash>;
|
||||
};
|
||||
|
||||
export default Import;
|
||||
@@ -0,0 +1,64 @@
|
||||
.pre {
|
||||
padding: 1rem;
|
||||
margin: 1rem 0 0 0;
|
||||
overflow: auto;
|
||||
width: calc(100vw - 2rem);
|
||||
background-color: var(--bg-code);
|
||||
align-items: center;
|
||||
display: flex;
|
||||
|
||||
/* Fixer pixelbug på høyre side av bash-panel */
|
||||
box-shadow: inset -4px 0 0 var(--bg-code);
|
||||
}
|
||||
|
||||
.preWrapper {
|
||||
position: relative;
|
||||
align-items: center;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.terminal {
|
||||
color: var(--color-code);
|
||||
}
|
||||
|
||||
.code {
|
||||
padding-right: 4rem;
|
||||
color: var(--color-code);
|
||||
}
|
||||
|
||||
.terminal::before {
|
||||
content: "$ ";
|
||||
}
|
||||
|
||||
.buttonBackground {
|
||||
width: 3rem;
|
||||
background-color: var(--bg-code);
|
||||
position: absolute;
|
||||
right: 0;
|
||||
margin: 1rem 0;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
height: calc(100% - 3rem - 0.5rem);
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.copyButton {
|
||||
background-color: var(--bg-code);
|
||||
color: white;
|
||||
font-size: 1.5rem;
|
||||
padding: 0.5rem;
|
||||
border: none;
|
||||
align-items: center;
|
||||
display: inline-flex;
|
||||
height: 2.5rem;
|
||||
width: 2.5rem;
|
||||
}
|
||||
|
||||
.copyButton:hover {
|
||||
background-color: rgba(255, 255, 255, 0.2);
|
||||
}
|
||||
|
||||
.copyButton:focus {
|
||||
outline: var(--outline-code);
|
||||
outline-offset: var(--outline-offset);
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
import Header from "./header/Header";
|
||||
import Sidebar from "./sidebar/Sidebar";
|
||||
import Mdx from "./MdxProvider";
|
||||
import Toc from "../toc/Toc";
|
||||
import { Grid, Cell, ContentContainer } from "@navikt/ds-react";
|
||||
import { useMediaQuery } from "react-responsive";
|
||||
import useKeypress from "react-use-keypress";
|
||||
import { useEffect, useState } from "react";
|
||||
import style from "./layout.module.css";
|
||||
|
||||
interface LayoutProps {
|
||||
children?: React.ReactNode;
|
||||
}
|
||||
|
||||
const Layout = ({ children }: LayoutProps) => {
|
||||
const [sidebar, setSidebar] = useState(false);
|
||||
|
||||
const small = useMediaQuery({
|
||||
query: "(max-width: 959px)",
|
||||
});
|
||||
|
||||
useKeypress("Escape", () => {
|
||||
setSidebar(false);
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
setSidebar(!small);
|
||||
}, [small]);
|
||||
|
||||
return (
|
||||
<div className={style.pageWrapper + " lightTheme"}>
|
||||
<Header sidebar={sidebar} onSidebarChange={(x) => setSidebar(x)} />
|
||||
<Sidebar
|
||||
sidebar={sidebar}
|
||||
small={small}
|
||||
onSidebarChange={(x) => setSidebar(x)}
|
||||
/>
|
||||
<main className={style.contentWrapper}>
|
||||
<ContentContainer>
|
||||
<Grid>
|
||||
<Cell className={style.content} xs={12} sm={12} md={10} lg={7}>
|
||||
<Mdx>{children}</Mdx>
|
||||
</Cell>
|
||||
<Cell xs={12} sm={1} md={2} lg={1} />
|
||||
<Cell xs={12} sm={12} md={8} lg={4}>
|
||||
<Toc />
|
||||
</Cell>
|
||||
</Grid>
|
||||
</ContentContainer>
|
||||
</main>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Layout;
|
||||
@@ -0,0 +1,25 @@
|
||||
import { MDXProvider } from "@mdx-js/react";
|
||||
import { Heading, Paragraph } from "@navikt/ds-react";
|
||||
import Bash from "../code/Bash";
|
||||
import Import from "../code/Import";
|
||||
import Preview from "../code-preview/Preview";
|
||||
import Npm from "../npm/Npm";
|
||||
/* import { Button } from "@navikt/ds-react"; */
|
||||
|
||||
const MdxWrapper = (props) => (
|
||||
<MDXProvider
|
||||
components={{
|
||||
h1: (props) => <Heading size="xxl" level={1} {...props} />,
|
||||
h2: (props) => <Heading size="large" level={2} {...props} />,
|
||||
h3: (props) => <Heading size="small" level={3} {...props} />,
|
||||
p: (props) => <Paragraph size="medium" {...props} />,
|
||||
Bash,
|
||||
Preview,
|
||||
Import,
|
||||
Npm,
|
||||
}}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
|
||||
export default MdxWrapper;
|
||||
@@ -0,0 +1,40 @@
|
||||
import Link from "next/link";
|
||||
import NavLogo from "../../assets/navLogo.svg";
|
||||
import { HamburgerFilled } from "@navikt/ds-icons";
|
||||
import cl from "classnames";
|
||||
import style from "../layout.module.css";
|
||||
|
||||
interface HeaderProps {
|
||||
className?: string;
|
||||
sidebar: boolean;
|
||||
onSidebarChange: (x: boolean) => void;
|
||||
}
|
||||
|
||||
const Header = ({
|
||||
className,
|
||||
sidebar,
|
||||
onSidebarChange,
|
||||
...props
|
||||
}: HeaderProps) => {
|
||||
return (
|
||||
<header className={style.header}>
|
||||
<button
|
||||
onClick={() => onSidebarChange(!sidebar)}
|
||||
className={cl(style.header__link, style.header__icon, {
|
||||
[style["header__icon--hidden"]]: sidebar,
|
||||
})}
|
||||
tabIndex={!sidebar ? 0 : -1}
|
||||
>
|
||||
<HamburgerFilled />
|
||||
</button>
|
||||
<Link href="/">
|
||||
<button className={style.header__link}>
|
||||
<NavLogo />
|
||||
<span className={style["header__link-title"]}>NAV Designsystem</span>
|
||||
</button>
|
||||
</Link>
|
||||
</header>
|
||||
);
|
||||
};
|
||||
|
||||
export default Header;
|
||||
@@ -0,0 +1,144 @@
|
||||
.pageWrapper {
|
||||
display: grid;
|
||||
grid-template-columns: auto 1fr;
|
||||
grid-template-rows: auto 1fr;
|
||||
grid-template-areas:
|
||||
"header header"
|
||||
"sidebar content";
|
||||
height: 100vh;
|
||||
background-color: var(--bg-primary);
|
||||
}
|
||||
|
||||
.header {
|
||||
grid-area: header;
|
||||
width: 100vw;
|
||||
display: flex;
|
||||
z-index: 99;
|
||||
color: #fff;
|
||||
height: 5rem;
|
||||
background-color: #c30000;
|
||||
}
|
||||
|
||||
.header__link {
|
||||
background: none;
|
||||
border: none;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
column-gap: 3rem;
|
||||
height: 100%;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.header__icon {
|
||||
color: #fff;
|
||||
font-size: 1.5rem;
|
||||
height: 5rem;
|
||||
width: 5rem;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.sidebar__icon {
|
||||
color: var(--navds-color-blue-50);
|
||||
height: 5rem;
|
||||
width: 5rem;
|
||||
font-size: 1.5rem;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
flex-shrink: 0;
|
||||
background: none;
|
||||
border: none;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.sidebar__icon:focus {
|
||||
outline: 2px solid var(--navds-color-blue-50);
|
||||
outline-offset: -2px;
|
||||
}
|
||||
|
||||
.header__icon--hidden {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.header__link:focus {
|
||||
outline: 2px solid white;
|
||||
outline-offset: -2px;
|
||||
}
|
||||
|
||||
.header__link-title {
|
||||
color: white;
|
||||
font-size: var(--navds-font-size-heading-large);
|
||||
font-weight: var(--navds-font-weight-bold);
|
||||
line-height: var(--navds-font-line-height-large);
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
display: flex;
|
||||
grid-area: sidebar;
|
||||
flex-direction: column;
|
||||
width: 300px;
|
||||
flex-grow: 1;
|
||||
flex-shrink: 1;
|
||||
background-color: var(--bg-secondary);
|
||||
box-shadow: inset -2px 0px 0px var(--sidebar-shadow);
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
.contentWrapper {
|
||||
grid-area: content;
|
||||
overflow-y: auto;
|
||||
overflow: visible;
|
||||
margin: 0 auto 0 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.content {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
@media (max-width: 959px) {
|
||||
.sidebar {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 447px) {
|
||||
.header__link {
|
||||
column-gap: 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
.sidebar__mobile {
|
||||
z-index: 999;
|
||||
display: flex;
|
||||
background-color: var(--bg-secondary);
|
||||
flex-direction: column;
|
||||
color: var(--text-color);
|
||||
overflow-y: auto;
|
||||
position: fixed;
|
||||
left: -300px;
|
||||
min-height: 100vh;
|
||||
border-right: var(--sidebar-divider);
|
||||
}
|
||||
|
||||
.sidebar__mobile--open {
|
||||
transition: transform 250ms cubic-bezier(0.6, 0.05, 0.28, 0.91);
|
||||
transform: translateX(100%);
|
||||
}
|
||||
|
||||
.sidebar--overlay {
|
||||
display: block;
|
||||
z-index: 200;
|
||||
background: rgba(0, 0, 0, 0);
|
||||
position: fixed;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
top: 0;
|
||||
transition: background 0.15s linear;
|
||||
}
|
||||
|
||||
.sidebar--overlay--fade {
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
import Link from "next/link";
|
||||
import cl from "classnames";
|
||||
import { Close } from "@navikt/ds-icons";
|
||||
import style from "../layout.module.css";
|
||||
|
||||
interface SidebarProps {
|
||||
classname?: string;
|
||||
sidebar: boolean;
|
||||
small: boolean;
|
||||
onSidebarChange: (x: boolean) => void;
|
||||
}
|
||||
|
||||
const Sidebar = ({
|
||||
sidebar,
|
||||
small,
|
||||
onSidebarChange,
|
||||
...props
|
||||
}: SidebarProps) => {
|
||||
return (
|
||||
<>
|
||||
{sidebar && small && (
|
||||
<div
|
||||
onClick={() => onSidebarChange(false)}
|
||||
className={cl(style["sidebar--overlay"], {
|
||||
[style["sidebar--overlay--fade"]]: sidebar,
|
||||
})}
|
||||
/>
|
||||
)}
|
||||
<div
|
||||
className={cl(style.sidebar, {
|
||||
[style.sidebar__mobile]: small,
|
||||
[style["sidebar__mobile--open"]]: small && sidebar,
|
||||
})}
|
||||
>
|
||||
{small && sidebar && (
|
||||
<button
|
||||
onClick={() => onSidebarChange(!sidebar)}
|
||||
className={style.sidebar__icon}
|
||||
>
|
||||
<Close />
|
||||
</button>
|
||||
)}
|
||||
<Link href="/">Home</Link>
|
||||
<Link href="/komponenter">Komponenter</Link>
|
||||
<Link href="/komponenter/button">Button</Link>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default Sidebar;
|
||||
@@ -0,0 +1,61 @@
|
||||
import getConfig from "next/config";
|
||||
import Import from "../code/Import";
|
||||
import style from "./npm.module.css";
|
||||
|
||||
const Npm = ({
|
||||
packName,
|
||||
imports,
|
||||
namedExport,
|
||||
}: {
|
||||
packName: string;
|
||||
imports: string | string[];
|
||||
namedExport?: boolean;
|
||||
}) => {
|
||||
const { publicRuntimeConfig } = getConfig();
|
||||
|
||||
const packs = publicRuntimeConfig.packages.filter(
|
||||
(pack) => pack.name === packName
|
||||
);
|
||||
|
||||
return (
|
||||
<div>
|
||||
{packs.map(({ name, data }) => (
|
||||
<div key={name}>
|
||||
<span className={style.badges}>
|
||||
<a
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
href={`https://www.npmjs.com/package/${name}`}
|
||||
>
|
||||
<img src={`https://badgen.net/npm/v/${name}`} alt="123" />
|
||||
</a>
|
||||
|
||||
<a
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
href={`https://bundlephobia.com/result?p=${name}`}
|
||||
>
|
||||
<img
|
||||
src={`https://badgen.net/bundlephobia/tree-shaking/${name}`}
|
||||
alt="123"
|
||||
/>
|
||||
</a>
|
||||
<a
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
href={`https://bundlephobia.com/result?p=${name}`}
|
||||
>
|
||||
<img
|
||||
src={`https://badgen.net/bundlephobia/min/${name}`}
|
||||
alt="123"
|
||||
/>
|
||||
</a>
|
||||
</span>
|
||||
<Import from={name} imports={imports} namedExport={namedExport} />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Npm;
|
||||
@@ -0,0 +1,5 @@
|
||||
.badges {
|
||||
display: flex;
|
||||
column-gap: 0.5rem;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import { useState } from "react";
|
||||
import style from "./tabs.module.css";
|
||||
import cl from "classnames";
|
||||
|
||||
interface TabsProps {
|
||||
onChange: (tab: number) => void;
|
||||
tabs: string[];
|
||||
}
|
||||
|
||||
const Tabs = ({ onChange, tabs, ...props }: TabsProps) => {
|
||||
const [tab, setTab] = useState(0);
|
||||
|
||||
const handleClick = (x: number) => {
|
||||
onChange(x);
|
||||
setTab(x);
|
||||
};
|
||||
|
||||
return (
|
||||
<ul className={style.ul}>
|
||||
{tabs.map((t, x) => (
|
||||
<li key={t + x} className={style.li}>
|
||||
<button
|
||||
className={cl(style.button, { [style.buttonActive]: x === tab })}
|
||||
onClick={() => handleClick(x)}
|
||||
>
|
||||
{t}
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
);
|
||||
};
|
||||
|
||||
export default Tabs;
|
||||
@@ -0,0 +1,32 @@
|
||||
.ul {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.li {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.button {
|
||||
color: var(--tab-color);
|
||||
border: none;
|
||||
background: none;
|
||||
padding: 0.5rem 1.5rem;
|
||||
font-weight: var(--navds-font-weight-bold);
|
||||
}
|
||||
|
||||
.button:hover {
|
||||
border-bottom: 4px solid var(--navds-color-darkgray);
|
||||
color: var(--navds-color-darkgray);
|
||||
}
|
||||
|
||||
.button:focus {
|
||||
outline: var(--outline-focus);
|
||||
outline-offset: var(--outline-offset);
|
||||
}
|
||||
|
||||
.buttonActive {
|
||||
border-bottom: var(--tab-border);
|
||||
color: var(--tab-color-active);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import style from "./toc.module.css";
|
||||
interface TocProps {
|
||||
className?: string;
|
||||
}
|
||||
|
||||
const Header = ({ className, ...props }: TocProps) => {
|
||||
return <nav className={style.toc}></nav>;
|
||||
};
|
||||
|
||||
export default Header;
|
||||
@@ -0,0 +1,6 @@
|
||||
.toc {
|
||||
background-color: var(--bg-secondary);
|
||||
width: 100%;
|
||||
height: 500px;
|
||||
outline: var(--outline);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/* const withBundleAnalyzer = require("@next/bundle-analyzer")({
|
||||
enabled: process.env.ANALYZE === "true",
|
||||
}); */
|
||||
const glob = require("glob");
|
||||
const withMDX = require("@next/mdx")({
|
||||
extension: /\.mdx?$/,
|
||||
});
|
||||
|
||||
const loadPackage = () => {
|
||||
const navFrontend = glob.sync("../packages/**/package.json");
|
||||
const vnext = glob.sync("../@navikt/*/package.json");
|
||||
return [...navFrontend, ...vnext]
|
||||
.filter((file) => !file.includes("node_modules"))
|
||||
.map((file) => {
|
||||
const pack = require(file);
|
||||
return { name: pack.name, data: pack };
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = withMDX({
|
||||
pageExtensions: ["js", "jsx", "mdx"],
|
||||
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
|
||||
config.module.rules.push({
|
||||
test: /\.svg$/,
|
||||
use: ["@svgr/webpack"],
|
||||
});
|
||||
return config;
|
||||
},
|
||||
publicRuntimeConfig: {
|
||||
packages: loadPackage(),
|
||||
},
|
||||
});
|
||||
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"name": "docs",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"build": "next build",
|
||||
"start": "next start"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/react": "^17.0.2",
|
||||
"next": "10.0.8",
|
||||
"react": "17.0.1",
|
||||
"react-dom": "17.0.1",
|
||||
"typescript": "^4.2.3",
|
||||
"react-responsive": "^8.2.0",
|
||||
"react-use-keypress": "^1.2.0",
|
||||
"classnames": "^2.2.6",
|
||||
"glob": "^7.1.6",
|
||||
"@next/mdx": "^10.0.8",
|
||||
"@mdx-js/loader": "^1.6.22",
|
||||
"@mdx-js/react": "^1.6.22",
|
||||
"copy-to-clipboard": "^3.3.1",
|
||||
"prismjs": "^1.23.0",
|
||||
"@svgr/webpack": "^5.5.0",
|
||||
"@navikt/ds-css": "^0.2.0",
|
||||
"@navikt/ds-react": "^0.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@next/bundle-analyzer": "^10.0.8",
|
||||
"@types/prettier": "^2.2.2",
|
||||
"@types/react-dom": "^17.0.2",
|
||||
"prettier": "2.2.1"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"rules": {
|
||||
"react/react-in-jsx-scope": "off"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import Head from "next/head";
|
||||
import { useRouter } from "next/router";
|
||||
import Layout from "../components/layout/Layout";
|
||||
import "../styles/theme.css";
|
||||
import "../styles/globals.css";
|
||||
import "../styles/prismjs.css";
|
||||
import "@navikt/ds-css";
|
||||
|
||||
const Website = ({ Component, pageProps }) => {
|
||||
const route = useRouter();
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>NAV Designsystem</title>
|
||||
<link rel="icon" href="/favicon-32x32.png" />
|
||||
</Head>
|
||||
<Layout route={route}>
|
||||
<Component {...pageProps} />
|
||||
</Layout>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default Website;
|
||||
@@ -0,0 +1,5 @@
|
||||
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
|
||||
|
||||
export default (req, res) => {
|
||||
res.status(200).json({ name: "John Doe" });
|
||||
};
|
||||
@@ -0,0 +1,5 @@
|
||||
# Home
|
||||
|
||||
Hjemmeside
|
||||
|
||||
<Npm packName="@navikt/ds-react" imports="Button" />
|
||||
@@ -0,0 +1,3 @@
|
||||
# Getting-started
|
||||
|
||||
Kom i gang
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
@@ -0,0 +1,4 @@
|
||||
<svg width="283" height="64" viewBox="0 0 283 64" fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M141.04 16c-11.04 0-19 7.2-19 18s8.96 18 20 18c6.67 0 12.55-2.64 16.19-7.09l-7.65-4.42c-2.02 2.21-5.09 3.5-8.54 3.5-4.79 0-8.86-2.5-10.37-6.5h28.02c.22-1.12.35-2.28.35-3.5 0-10.79-7.96-17.99-19-17.99zm-9.46 14.5c1.25-3.99 4.67-6.5 9.45-6.5 4.79 0 8.21 2.51 9.45 6.5h-18.9zM248.72 16c-11.04 0-19 7.2-19 18s8.96 18 20 18c6.67 0 12.55-2.64 16.19-7.09l-7.65-4.42c-2.02 2.21-5.09 3.5-8.54 3.5-4.79 0-8.86-2.5-10.37-6.5h28.02c.22-1.12.35-2.28.35-3.5 0-10.79-7.96-17.99-19-17.99zm-9.45 14.5c1.25-3.99 4.67-6.5 9.45-6.5 4.79 0 8.21 2.51 9.45 6.5h-18.9zM200.24 34c0 6 3.92 10 10 10 4.12 0 7.21-1.87 8.8-4.92l7.68 4.43c-3.18 5.3-9.14 8.49-16.48 8.49-11.05 0-19-7.2-19-18s7.96-18 19-18c7.34 0 13.29 3.19 16.48 8.49l-7.68 4.43c-1.59-3.05-4.68-4.92-8.8-4.92-6.07 0-10 4-10 10zm82.48-29v46h-9V5h9zM36.95 0L73.9 64H0L36.95 0zm92.38 5l-27.71 48L73.91 5H84.3l17.32 30 17.32-30h10.39zm58.91 12v9.69c-1-.29-2.06-.49-3.2-.49-5.81 0-10 4-10 10V51h-9V17h9v9.2c0-5.08 5.91-9.2 13.2-9.2z" fill="#000"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
Loaded 100 of 174 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user