✨ Add css package (@navikt/ds-css) with Button and typography styles

Styles reference CSS custom properties from @navikt/ds-tokens.
build.mjs copies source stylesheets to dist/.
This commit is contained in:
Aksel Mini committed 2026-08-06 13:45:00 +02:00
1 parent 7382e691ef
commit b4930f754e
6 files changed
+178

No files matched your search

+17
View File
@@ -0,0 +1,17 @@
import { mkdirSync, readdirSync, copyFileSync } from "node:fs";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
const root = dirname(fileURLToPath(import.meta.url));
const src = join(root, "src");
const dist = join(root, "dist");
mkdirSync(dist, { recursive: true });
for (const file of readdirSync(src)) {
if (file.endsWith(".css")) {
copyFileSync(join(src, file), join(dist, file));
}
}
console.log(`Copied styles to dist/`);
+17
View File
@@ -0,0 +1,17 @@
{
"name": "@navikt/ds-css",
"version": "0.1.0",
"description": "Component styles for Aksel Mini, built on @navikt/ds-tokens",
"license": "MIT",
"type": "module",
"files": [
"dist"
],
"scripts": {
"build": "node build.mjs",
"clean": "rm -rf dist"
},
"devDependencies": {
"@navikt/ds-tokens": "workspace:*"
}
}
+84
View File
@@ -0,0 +1,84 @@
/**
* Button
*/
.navds-button {
display: inline-flex;
align-items: center;
justify-content: center;
gap: var(--a-spacing-2);
padding: var(--a-spacing-2) var(--a-spacing-4);
border: 2px solid transparent;
border-radius: var(--a-border-radius-medium);
font-family: var(--a-font-family);
font-size: var(--a-font-size-md);
font-weight: var(--a-font-weight-bold);
line-height: 1.375;
text-decoration: none;
cursor: pointer;
}
.navds-button--small {
padding: var(--a-spacing-1) var(--a-spacing-3);
font-size: var(--a-font-size-xs);
}
.navds-button--primary {
background-color: var(--a-surface-action);
color: var(--a-text-on-action);
}
.navds-button--primary:hover {
background-color: var(--a-surface-action-hover);
}
.navds-button--primary:active {
background-color: var(--a-surface-action-active);
}
.navds-button--secondary {
background-color: transparent;
border-color: var(--a-border-action);
color: var(--a-text-default);
}
.navds-button--secondary:hover {
background-color: var(--a-surface-action);
border-color: var(--a-surface-action);
color: var(--a-text-on-action);
}
.navds-button--tertiary {
background-color: transparent;
border-color: transparent;
color: var(--a-text-default);
text-decoration: underline;
}
.navds-button--tertiary:hover {
background-color: var(--a-bg-subtle);
}
.navds-button--danger {
background-color: var(--a-surface-danger);
color: var(--a-text-on-danger);
}
.navds-button--danger:hover {
background-color: var(--a-surface-danger-hover);
}
.navds-button:focus {
outline: none;
}
.navds-button:focus-visible {
outline: 2px solid var(--a-border-focus);
outline-offset: 2px;
}
.navds-button:disabled,
.navds-button[aria-disabled="true"] {
opacity: 0.5;
cursor: not-allowed;
}
+4
View File
@@ -0,0 +1,4 @@
/* Make sure @navikt/ds-tokens/dist/tokens.css is loaded first. */
@import "./tokens-layer.css";
@import "./typography.css";
@import "./button.css";
+4
View File
@@ -0,0 +1,4 @@
/**
* Placeholder layer kept for future @layer ordering.
* Token custom properties come from @navikt/ds-tokens.
*/
+52
View File
@@ -0,0 +1,52 @@
/**
* Typography: BodyShort and Heading
*/
.navds-body-short {
margin: 0;
font-family: var(--a-font-family);
font-weight: var(--a-font-weight-regular);
color: var(--a-text-default);
}
.navds-body-short--medium {
font-size: var(--a-font-size-md);
line-height: 1.5;
}
.navds-body-short--small {
font-size: var(--a-font-size-xs);
line-height: 1.5;
}
.navds-heading {
margin: 0;
font-family: var(--a-font-family);
font-weight: var(--a-font-weight-bold);
color: var(--a-text-default);
}
.navds-heading--xsmall {
font-size: var(--a-font-size-heading-xsmall);
line-height: 1.4;
}
.navds-heading--small {
font-size: var(--a-font-size-heading-small);
line-height: 1.4;
}
.navds-heading--medium {
font-size: var(--a-font-size-heading-medium);
line-height: 1.4;
}
.navds-heading--large {
font-size: var(--a-font-size-heading-large);
line-height: 1.3;
}
.navds-heading--xlarge {
font-size: var(--a-font-size-heading-xlarge);
line-height: 1.2;
}