Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Move code of Foundation used for badges to the core file and remove the rest

Henriette Darge25335fd7340a
diff --git a/frontend/src/global_styles/content/_badges.sass b/frontend/src/global_styles/content/_badges.sass
index ec0980c2ca2..e5de56787b1 100644
--- a/frontend/src/global_styles/content/_badges.sass
+++ b/frontend/src/global_styles/content/_badges.sass
@@ -27,16 +27,40 @@
//++
$badge-diameter: 1.25rem
+$badge-fontsize: 1rem
+$badge-background: var(--primary-color)
+$badge-secondary-background: #F1F1F1
+$badge-color: var(--font-color-on-primary)
+
+@mixin badge-layout($fontsize: $badge-fontsize, $diameter: $badge-diameter)
+ font-size: $fontsize
+ width: $diameter
+ height: $diameter
+
+@mixin badge-style($background: $badge-background, $color: $badge-color)
+ background: $background
+
+ @if $color == auto
+ color: is-light($background)
+
+ @else
+ color: $color
+
.badge
- @include badge
+ display: inline-flex
+ align-items: center
+ justify-content: center
+ border-radius: 1000px
+ @include badge-layout
+ @include badge-style
width: auto
min-width: 1.25rem
padding-left: 0.3rem
padding-right: 0.3rem
&.-secondary
- @include badge-style($secondary-color, auto)
+ @include badge-style($badge-secondary-background, auto)
&.-border-only
border-color: var(--button--border-color)
diff --git a/frontend/src/global_styles/openproject/_functions.sass b/frontend/src/global_styles/openproject/_functions.sass
index dbb734607cd..94dc926bc39 100644
--- a/frontend/src/global_styles/openproject/_functions.sass
+++ b/frontend/src/global_styles/openproject/_functions.sass
@@ -33,3 +33,10 @@
@each $pixel-val in $list-of-pixels
$result: $result + rem-calc($pixel-val) + ' '
@return #{$result}
+
+@function is-light($color, $yes: #000, $no: #fff, $threshold: 60%)
+ @if (lightness($color) > $threshold)
+ @return $yes
+
+ @else
+ @return $no
diff --git a/frontend/src/global_styles/vendor/foundation-apps/scss/components/_label.scss b/frontend/src/global_styles/vendor/foundation-apps/scss/components/_label.scss
deleted file mode 100644
index ecda1fd4a99..00000000000
--- a/frontend/src/global_styles/vendor/foundation-apps/scss/components/_label.scss
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- Label
-*/
-
-/// @Foundation.settings
-// Label
-@use "sass:math";
-
-$label-fontsize: 0.8rem !default;
-$label-padding: math.div($global-padding, 3) ($global-padding * 0.5) !default;
-$label-radius: 0 !default;
-$label-background: $primary-color !default;
-$label-color: isitlight($primary-color) !default;
-
-$badge-fontsize: 0.8em !default;
-$badge-diameter: 1.5rem !default;
-$badge-background: $primary-color !default;
-$badge-color: #fff !default;
-///
-
-%label {
- line-height: 1;
- white-space: nowrap;
- display: inline-block;
- cursor: default;
-}
-
-@mixin label-layout(
- $fontsize: $label-fontsize,
- $padding: $label-padding
-) {
- font-size: $fontsize;
- padding: $padding;
-}
-
-@mixin label-style(
- $background: $label-background,
- $color: $label-color,
- $radius: $label-radius
-) {
- background: $background;
- border-radius: $radius;
-
- @if $color == auto {
- color: isitlight($background);
- }
- @else {
- color: $color;
- }
-}
-
-@mixin label(
- $background: $label-background,
- $color: $label-color,
- $radius: $label-radius,
- $fontsize: $label-fontsize,
- $padding: $label-padding
-) {
- @extend %label;
- @include label-layout($fontsize, $padding);
- @include label-style($background, $color, $radius);
-}
-
-@include exports(label) {
- .label {
- @include label;
-
- @each $color in map-keys($foundation-colors) {
- &.#{$color} {
- $color-value: map-get($foundation-colors, $color);
- @include label-style($color-value, auto);
- }
- }
- }
-}
-
-/*
- Badge
-*/
-
-%badge {
- align-items: center;
- justify-content: center;
- display: inline-flex;
- border-radius: 1000px;
-}
-
-@mixin badge-layout(
- $fontsize: $badge-fontsize,
- $diameter: $badge-diameter
-) {
- font-size: $fontsize;
- width: $diameter;
- height: $diameter;
-}
-
-@mixin badge-style(
- $background: $badge-background,
- $color: $badge-font-color
-) {
- background: $background;
-
- @if $color == auto {
- color: isitlight($background);
- }
- @else {
- color: $color;
- }
-}
-
-@mixin badge(
- $background: $badge-background,
- $color: $badge-color,
- $diameter: $badge-diameter,
- $fontsize: $badge-fontsize
-) {
- @extend %badge;
- @include badge-layout($fontsize, $diameter);
- @include badge-style($background, $color);
-}
-
-@include exports(badge) {
- .badge {
- @include badge;
-
- &.secondary {
- @include badge-style($secondary-color, auto);
- }
- @each $color in map-keys($foundation-colors) {
- &.#{$color} {
- $color-value: map-get($foundation-colors, $color);
- @include badge-style($color-value, auto);
- }
- }
- }
-}
diff --git a/frontend/src/global_styles/vendor/foundation-apps/scss/foundation.scss b/frontend/src/global_styles/vendor/foundation-apps/scss/foundation.scss
index 424db179352..44046f5e6f7 100755
--- a/frontend/src/global_styles/vendor/foundation-apps/scss/foundation.scss
+++ b/frontend/src/global_styles/vendor/foundation-apps/scss/foundation.scss
@@ -24,7 +24,6 @@ $foundation-version: '1.1.0';
@import "components/button",
"components/forms",
"components/grid",
-"components/label",
"components/motion",
"components/tabs",
"components/typography",