Skip to content

feat: moved Base aspects from DB UI Core to DB UI Base #139

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
"zeplin:tokens": "node scripts/zeplin-styleguide.js"
},
"license": "Apache-2.0",
"dependencies": {
"@csstools/normalize.css": "^12.0.0"
},
"devDependencies": {
"@commitlint/cli": "17.2.0",
"@commitlint/config-conventional": "17.2.0",
Expand Down
5 changes: 4 additions & 1 deletion scripts/color-classes-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ const generateBGVariants = (value, index) => {
* @returns scss string
*/
exports.generateColorUtilitityClasses = (colorToken) => {
let output = '@import "variables";\n@import "color-placeholder";\n';
let output = `
@use "variables" as *;
@use "color-placeholder" as *;
`;

for (const [, value] of Object.keys(colorToken).entries()) {
output += `/**
Expand Down
2 changes: 1 addition & 1 deletion scripts/color-placeholders-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const generateBGVariants = (
* @returns scss string
*/
exports.generateColorUtilitityPlaceholder = (colorToken) => {
let output = '';
let output = '@use "variables" as *;\n';

for (const [, value] of Object.keys(colorToken).entries()) {
output += `/**
Expand Down
4 changes: 2 additions & 2 deletions scripts/scss-scaling-generator.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const fileHeader =
'\n' +
'@use "variables" as *;\n' +
'// Do not edit directly\n' +
'// Generated on ' +
new Date().toString() +
Expand All @@ -9,7 +9,7 @@ const generateSpacings = (utility) => {
let allClasses = fileHeader;

if (utility) {
allClasses += `@import "variables";\n@import "scaling-placeholder";\n`;
allClasses += `@use "scaling-placeholder" as *;\n`;
}

const scaleTypeKey = ['normal', 'functional', 'expressive'];
Expand Down
15 changes: 8 additions & 7 deletions scripts/scss-typography-generator.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
const prefix = 'db';

const fileHeader =
'@import "icon-family-calc";\n' +
'// Do not edit directly\n' +
'// Generated on ' +
new Date().toString() +
'\n';
const fileHeader = `
@use "variables" as *;
@use "icon/icon-family-calc" as *;
// Do not edit directly
// Generated on
// ${new Date().toString()}
`;

const getShortSize = (size) => {
if (size === '3xlarge') {
Expand Down Expand Up @@ -112,7 +113,7 @@ const generateClasses = (typography, utility) => {
let allClasses = fileHeader;

if (utility) {
allClasses += `@import "variables";\n@import "typography-placeholder";\n`;
allClasses += `@use "variables" as *;\n@use "typography-placeholder" as *;\n`;
}

// ScaleTypeKey = [normal, functional, expressive]
Expand Down
3 changes: 3 additions & 0 deletions scss/_default.assets-paths.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$icons-path: "assets/icons/" !default;
$images-path: "assets/images/" !default;
$fonts-path: "assets/fonts/" !default;
19 changes: 11 additions & 8 deletions scss/_font-faces.scss
Original file line number Diff line number Diff line change
@@ -1,35 +1,38 @@
@use "variables" as *;
@use "default.assets-paths" as *;

@font-face {
font-family: $db-font-db-screenhead-light-font-family;
font-style: normal;
font-weight: $db-font-db-screenhead-light-font-weight;
src: local($db-font-db-screenhead-light-name),
url($db-font-db-screenhead-light-woff2) format("woff2"),
url($db-font-db-screenhead-light-woff) format("woff");
url($fonts-path + $db-font-db-screenhead-light-woff2) format("woff2"),
url($fonts-path + $db-font-db-screenhead-light-woff) format("woff");
}

@font-face {
font-family: $db-font-db-screenhead-black-font-family;
font-style: normal;
font-weight: $db-font-db-screenhead-black-font-weight;
src: local($db-font-db-screenhead-black-name),
url($db-font-db-screenhead-black-woff2) format("woff2"),
url($db-font-db-screenhead-black-woff) format("woff");
url($fonts-path + $db-font-db-screenhead-black-woff2) format("woff2"),
url($fonts-path + $db-font-db-screenhead-black-woff) format("woff");
}

@font-face {
font-family: $db-font-db-screensans-regular-font-family;
font-style: normal;
font-weight: $db-font-db-screensans-regular-font-weight;
src: local($db-font-db-screensans-regular-name),
url($db-font-db-screensans-regular-woff2) format("woff2"),
url($db-font-db-screensans-regular-woff) format("woff");
url($fonts-path + $db-font-db-screensans-regular-woff2) format("woff2"),
url($fonts-path + $db-font-db-screensans-regular-woff) format("woff");
}

@font-face {
font-family: $db-font-db-screensans-bold-font-family;
font-style: normal;
font-weight: $db-font-db-screensans-bold-font-weight;
src: local($db-font-db-screensans-bold-name),
url($db-font-db-screensans-bold-woff2) format("woff2"),
url($db-font-db-screensans-bold-woff) format("woff");
url($fonts-path + $db-font-db-screensans-bold-woff2) format("woff2"),
url($fonts-path + $db-font-db-screensans-bold-woff) format("woff");
}
4 changes: 4 additions & 0 deletions scss/_rollup.assets-paths.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// If this library is used as an npm dependency, and the source files should be included rather than css, this corrects the paths.
$icons-path: "@db-ui/core/dist/icons/";
$images-path: "@db-ui/core/dist/images/";
$fonts-path: "@db-ui/core/dist/fonts/";
17 changes: 9 additions & 8 deletions scss/_tonality.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@import "font-faces";
@import "typography-placeholder";
@import "scaling-placeholder";
@use "variables" as *;
@use "font-faces" as *;
@use "typography-placeholder" as *;
@use "scaling-placeholder" as *;

:root {
font-family: $db-font-family-sans;
Expand All @@ -21,15 +22,15 @@
.db-ui-#{nth($styles, $i + 1)} {
@extend %db-scaling-#{nth($styles, $i + 1)};

[data-size="large"] {
@extend %db-#{nth($styles, $i + 1)}-body-lg;
}

:not(small),
*,
[data-size="medium"] {
@extend %db-#{nth($styles, $i + 1)}-body-md;
}

[data-size="large"] {
@extend %db-#{nth($styles, $i + 1)}-body-lg;
}

small,
[data-size="small"] {
@extend %db-#{nth($styles, $i + 1)}-body-sm;
Expand Down
4 changes: 4 additions & 0 deletions scss/_webpack.assets-paths.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// If this library is used as an npm dependency, and the source files should be included rather than css, this corrects the paths.
$icons-path: "~@db-ui/core/dist/icons/";
$images-path: "~@db-ui/core/dist/images/";
$fonts-path: "~@db-ui/core/dist/fonts/";
10 changes: 6 additions & 4 deletions scss/db-ui-base.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
@import "variables";
@import "variables.global";
@import "color-placeholder";
@import "tonality";
@use "@csstools/normalize.css/normalize.css";

@use "variables" as *;
@use "variables.global" as *;
@use "color-placeholder" as *;
@use "tonality" as *;

:root {
@extend %db-ui-normal;
Expand Down
8 changes: 8 additions & 0 deletions scss/helpers/_a11y.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
%a11y-visually-hidden {
clip: rect(0, 0, 0, 0);
height: 1px;
overflow: hidden;
position: absolute !important;
white-space: nowrap;
width: 1px;
}
5 changes: 5 additions & 0 deletions scss/helpers/_clearfix.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
%clearfix::after {
clear: both;
content: " ";
display: table;
}
37 changes: 37 additions & 0 deletions scss/helpers/_functions.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
@use "sass:math";
@use "a11y" as *;
@use "clearfix" as *;

@function to-rem($pxValue) {
@return #{$pxValue * 0.0625}rem;
}

@function to-em($pxValue) {
@return #{$pxValue * 0.0625}em;
}

// TODO: We might be able to simplify the following placeholder/mixins afterwards by partial construct out of DB UI Core
// Mixin wrappers around the SCSS placeholders
@mixin a11y-visually-hidden($partial: false) {
@if $partial {
clip: rect(0, 0, 0, 0);
height: 1px;
overflow: hidden;
position: absolute !important;
white-space: nowrap;
width: 1px;
} @else {
@extend %a11y-visually-hidden;
}
}
@mixin clearfix($partial: false) {
@if $partial {
&::after {
clear: both;
content: " ";
display: table;
}
} @else {
@extend %clearfix;
}
}
File renamed without changes.
14 changes: 14 additions & 0 deletions scss/icon/_icons.attributes-mappings.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@use "icons.variables" as *;

// *** Attribute based method ***
@each $icon-name, $icon-glyph in $icon-glyphs {
[data-icon="#{$icon-name}"],
[data-icon-before="#{$icon-name}"] {
&::before {
--icon-glyph: "#{$icon-glyph}";
}
}
[data-icon-after="#{$icon-name}"]::after {
--icon-glyph: "#{$icon-glyph}";
}
}
35 changes: 35 additions & 0 deletions scss/icon/_icons.custom-properties.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@use "icons.variables" as *;
@use "icons.helpers" as *;
@use "icons.placeholder" as *;

// TODO: The following construct was especially meant to enable a branch (EDS & FV) specific result - probably we could refactor this the sooner the later
[data-icon]:not([data-icon-variant]),
[data-icon-before]:not([data-icon-variant-before]) {
&::before {
@extend %default-icon-custom-properties !optional;
}
}

[data-icon-after]:not([data-icon-variant-after]) {
&::after {
@extend %default-icon-custom-properties !optional;
}
}

// DB UX Icons
@each $icon-style, $icon-sizes in $icon-font-families-personenverkehr {
@each $icon-size, $icon-categories in $icon-sizes {
[data-icon-variant="#{$icon-size}-#{$icon-style}"],
[data-icon-variant-before="#{$icon-size}-#{$icon-style}"] {
&[data-icon],
&[data-icon-before] {
@include icon-meta($icon-size, $icon-style);
}
}
[data-icon-variant-after="#{$icon-size}-#{$icon-style}"] {
&[data-icon-after] {
@include icon-meta($icon-size, $icon-style, "after");
}
}
}
}
36 changes: 36 additions & 0 deletions scss/icon/_icons.font-faces.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
@use "icons.variables" as *;
@use "../default.assets-paths" as *;

// Potential TODO: usage of the standard filenames described by https://marketingportal.extranet.deutschebahn.com/de/icons-2

@font-face {
font-display: block;
font-family: "missing-icons";
src: url("#{$icons-path}functional/fonts/icons-empty.woff2?4r2095")
format("woff2"),
url("#{$icons-path}functional/fonts/icons-empty.woff?4r2095")
format("woff");
}

// DB UX Icons
@each $icon-style, $icon-sizes in $icon-font-families-personenverkehr {
@each $icon-size, $icon-categories in $icon-sizes {
@each $icon-category, $icon-font-unicodes in $icon-categories {
@font-face {
$icon-font-family: "icons-" + $icon-size + "-" + $icon-style;

font-display: block;

font-family: $icon-font-family;
font-style: normal;
font-weight: normal;
src: url("#{$icons-path}functional/fonts/#{$icon-font-family+ "-" + $icon-category}.woff2?4r2095")
format("woff2"),
url("#{$icons-path}functional/fonts/#{$icon-font-family+ "-" + $icon-category}.woff?4r2095")
format("woff");

unicode-range: unquote($icon-font-unicodes);
}
}
}
}
Loading