Skip to content
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

feat: allow global LF namespace #3110

Open
wants to merge 7 commits into
base: rc
Choose a base branch
from
Open
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
7 changes: 6 additions & 1 deletion package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"date-fns": "^3.6.0",
"isomorphic-dompurify": "^2.11.0",
"libphonenumber-js": "^1.11.5",
"normalize.css": "^8.0.1",
"normalize-scss": "^8.0.0",
"rxjs": "^7.8.1",
"tslib": "^2.6.2",
"zone.js": "~0.14.6"
Expand Down
4 changes: 2 additions & 2 deletions packages/icons/src/commons/base.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@use '@lucca-front/icons/src/commons/config';

@if config.$isNamespaced {
& {
@if config.$namespace {
#{config.$namespace} {
-moz-osx-font-smoothing: grayscale;
}
} @else {
Expand Down
2 changes: 1 addition & 1 deletion packages/icons/src/commons/config.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// $font-path: '../../font/lucca-icons' !default;
$font-path: '//cdn.lucca.fr/lucca-front/icons/font/lucca-icons' !default;
$font-name: 'Lucca icons' !default;
$isNamespaced: false !default;
$namespace: null !default;

$icons: (
'app': '\e959',
Expand Down
30 changes: 30 additions & 0 deletions packages/icons/src/commons/core.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
@use 'sass:string';
@use 'sass:list';

@use '@lucca-front/icons/src/commons/config';

@function capitalize($string) {
@return string.to-upper-case(string.slice($string, 1, 1)) + string.slice($string, 2);
}
Expand Down Expand Up @@ -34,3 +36,31 @@

@return $string;
}

// This mixin allows style to be applied at the root of the document or at the root of a namespace.
// It also allows to keep component nested inside the selector based on the $nestChildren parameter.
@mixin atRoot($nestChildren: false) {
@if $nestChildren {
// When atRoot is used inside a selector with $nestChildren set to true,
// the content is kept inside the selector.
// Example: .parent { @include atRoot { .child { color: red; } } }
// Output: .parent .child { color: red; }
@content;
} @else {
@at-root {
@if config.$namespace {
// When a namespace is set, the content is wrapped inside it.
// Example: .parent { @include atRoot($nestChildren: false) { .child { color: red; } } }
// Output: .namespace .child { color: red; }
#{config.$namespace} {
@content;
}
} @else {
// When no namespace is set, the content is kept at the root.
// Example: .parent { @include atRoot($nestChildren: false) { .child { color: red; } } }
// Output: .child { color: red; }
@content;
}
}
}
}
6 changes: 2 additions & 4 deletions packages/icons/src/icon/component.scss
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
@use '@lucca-front/icons/src/commons/config';
@use '@lucca-front/icons/src/commons/core';

$defaultAtRoot: config.$isNamespaced and 'with: rule' or 'without: rule';

@mixin component($atRoot: $defaultAtRoot) {
@mixin component($nestChildren: true) {
font-weight: 400;
font-size: var(--icon-size, var(--icon-sizeDefault));
direction: ltr;
Expand All @@ -19,7 +17,7 @@ $defaultAtRoot: config.$isNamespaced and 'with: rule' or 'without: rule';
white-space: nowrap;
word-wrap: normal;

@at-root ($atRoot) {
@include core.atRoot($nestChildren) {
@each $name, $value in config.$icons {
.icon-#{core.camelize($name)} {
--icon-content: '#{$value}';
Expand Down
50 changes: 27 additions & 23 deletions packages/icons/src/icon/index.scss
Original file line number Diff line number Diff line change
@@ -1,34 +1,38 @@
@use '@lucca-front/icons/src/commons/core';

@use 'exports' as *;

.lucca-icon {
@include vars;
@include component;
@include core.atRoot {
.lucca-icon {
@include vars;
@include component($nestChildren: false);

&.mod-XXS {
@include XXS;
}
&.mod-XXS {
@include XXS;
}

&.mod-XS {
@include XS;
}
&.mod-XS {
@include XS;
}

&.mod-S {
@include S;
}
&.mod-S {
@include S;
}

&.mod-M {
@include M;
}
&.mod-M {
@include M;
}

&.mod-L {
@include L;
}
&.mod-L {
@include L;
}

&.mod-XL {
@include XL;
}
&.mod-XL {
@include XL;
}

&.mod-XXL {
@include XXL;
&.mod-XXL {
@include XXL;
}
}
}
4 changes: 2 additions & 2 deletions packages/ng/styles/components/_calendar.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@use '@lucca-front/scss/src/commons/utils/namespace';
@use '@lucca-front/scss/src/commons/core';

@include namespace.appendRootVars {
@include core.appendRootVars {
--components-calendar-width: 17.5rem;
--components-calendar-day-size: 2.5rem;
}
116 changes: 59 additions & 57 deletions packages/ng/styles/components/_dropdown.scss
Original file line number Diff line number Diff line change
@@ -1,78 +1,80 @@
@use '@lucca-front/scss/src/commons/utils/namespace';
@use '@lucca-front/scss/src/commons/core';
@use '@lucca-front/scss/src/commons/utils/a11y';

@include namespace.appendRootVars {
@include core.appendRootVars {
--components-dropdown-min-width: 10rem;
--components-dropdown-max-width: 30rem;
--components-dropdown-max-height: 60vh;
}

.lu-dropdown-content {
margin: calc(var(--pr-t-spacings-100) * -1);
padding: 0;
border-radius: var(--commons-borderRadius-M);
max-width: 90vw;
max-height: var(--components-dropdown-max-height);
overflow-x: hidden;
overflow-y: auto;
}

.lu-dropdown-options {
list-style-type: none;
padding: var(--pr-t-spacings-100) 0;
margin: 0;
min-width: var(--components-dropdown-min-width);
max-width: var(--components-dropdown-max-width);
}

.lu-dropdown-options-item {
padding: 0 var(--pr-t-spacings-100);
}

.lu-dropdown-options-item-action {
align-items: flex-start;
background-color: transparent;
border: 0;
border-radius: var(--commons-borderRadius-M);
color: currentColor;
cursor: pointer;
display: flex;
gap: var(--pr-t-spacings-100);
line-height: var(--sizes-M-lineHeight);
padding: var(--pr-t-spacings-100) var(--pr-t-spacings-100);
text-align: left;
transition: background-color var(--commons-animations-durations-standard);
text-decoration: none;
width: 100%;

.lucca-icon {
font-size: var(--sizes-M-lineHeight);
@include core.atRoot {
.lu-dropdown-content {
margin: calc(var(--pr-t-spacings-100) * -1);
padding: 0;
border-radius: var(--commons-borderRadius-M);
max-width: 90vw;
max-height: var(--components-dropdown-max-height);
overflow-x: hidden;
overflow-y: auto;
}

&:hover {
background-color: var(--palettes-neutral-50);
color: currentColor;
.lu-dropdown-options {
list-style-type: none;
padding: var(--pr-t-spacings-100) 0;
margin: 0;
min-width: var(--components-dropdown-min-width);
max-width: var(--components-dropdown-max-width);
}

&:focus-visible {
@include a11y.focusVisible();
background-color: var(--palettes-neutral-50);
.lu-dropdown-options-item {
padding: 0 var(--pr-t-spacings-100);
}

&.is-disabled {
color: var(--commons-disabled-placeholder);
pointer-events: none;
.lu-dropdown-options-item-action {
align-items: flex-start;
background-color: transparent;
border: 0;
border-radius: var(--commons-borderRadius-M);
color: currentColor;
cursor: pointer;
display: flex;
gap: var(--pr-t-spacings-100);
line-height: var(--sizes-M-lineHeight);
padding: var(--pr-t-spacings-100) var(--pr-t-spacings-100);
text-align: left;
transition: background-color var(--commons-animations-durations-standard);
text-decoration: none;
width: 100%;

.lucca-icon {
font-size: var(--sizes-M-lineHeight);
}

&:hover {
background-color: var(--pr-t-elevation-surface-raised);
background-color: var(--palettes-neutral-50);
color: currentColor;
}
}

&.mod-delete {
color: var(--palettes-error-800);
&:focus-visible {
@include a11y.focusVisible();
background-color: var(--palettes-neutral-50);
}

&:hover {
background-color: var(--palettes-error-50);
&.is-disabled {
color: var(--commons-disabled-placeholder);
pointer-events: none;

&:hover {
background-color: var(--pr-t-elevation-surface-raised);
}
}

&.mod-delete {
color: var(--palettes-error-800);

&:hover {
background-color: var(--palettes-error-50);
}
}
}
}
Loading