Skip to content

Commit e601117

Browse files
committed
Add template and styling for toggle button
1 parent 1cb276b commit e601117

5 files changed

Lines changed: 136 additions & 5 deletions

File tree

web/themes/custom/hoeringsportal/assets/css/_bootstrap-custom.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ $color-white: $white;
5454
$color-petroleum-100: oklch(98% 0.017 196.88);
5555
$color-petroleum-200: oklch(90% 0.017 196.88);
5656
$color-petroleum-800: oklch(43% 0.063 196.55);
57+
$color-petroleum-900: oklch(30% 0.0406 197.75);
5758
$color-peach-100: oklch(94% 0.02 56.12);
5859
$color-peach-200: oklch(90% 0.02 56.12);
5960
$color-peach-600: oklch(50% 0.02 56.12);

web/themes/custom/hoeringsportal/assets/css/module/_btn.scss

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,68 @@
1818
}
1919
}
2020
}
21+
22+
.btn-toggle {
23+
background: $color-petroleum-800;
24+
border: none;
25+
border-radius: 4px;
26+
padding: 0;
27+
cursor: pointer;
28+
29+
&:has(input.btn-check:checked) {
30+
background: $color-petroleum-900;
31+
}
32+
33+
input.btn-check {
34+
&:checked + .toggle-badge {
35+
color: white;
36+
background-color: $color-petroleum-800;
37+
border: 1px solid $color-petroleum-800;
38+
transform: translateY(-2px);
39+
40+
&:hover {
41+
background-color: $color-petroleum-800;
42+
}
43+
}
44+
}
45+
46+
label.toggle-badge {
47+
display: block;
48+
background: white;
49+
border-radius: 4px;
50+
font-weight: 400;
51+
font-size: $font-size-small;
52+
border: 1px solid $color-petroleum-800;
53+
color: $color-petroleum-800;
54+
padding: 8px 12px;
55+
margin-bottom: 0;
56+
57+
@media (prefers-reduced-motion: no-preference) {
58+
transition:
59+
transform 300ms cubic-bezier(0.3, 0.7, 0.4, 1),
60+
background-color 0.1s ease-in;
61+
}
62+
}
63+
64+
&:hover label.toggle-badge {
65+
color: $color-petroleum-800;
66+
background-color: $color-petroleum-100;
67+
border: 1px solid $color-petroleum-800;
68+
69+
@media (prefers-reduced-motion: no-preference) {
70+
transform: translateY(-2px);
71+
transition:
72+
transform 200ms cubic-bezier(0.3, 0.7, 0.4, 1.5),
73+
background-color 0.2s ease-out;
74+
}
75+
}
76+
77+
&:active label.toggle-badge {
78+
@media (prefers-reduced-motion: no-preference) {
79+
transform: translateY(-2px);
80+
transition:
81+
transform 34ms,
82+
background-color 0.2s ease-out;
83+
}
84+
}
85+
}

web/themes/custom/hoeringsportal/assets/css/module/_dialogue.scss

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.proposal-layout {
2-
max-width: 840px!important;
2+
max-width: 840px !important;
33
}
44

55
.breadcrumb {
@@ -19,7 +19,7 @@
1919
.node-dialogue-proposal-form {
2020
label {
2121
font-weight: 700;
22-
margin-bottom: .5rem;
22+
margin-bottom: 0.5rem;
2323
}
2424

2525
.image-widget {
@@ -51,14 +51,28 @@
5151
@extend .btn;
5252
@extend .btn-primary;
5353

54-
padding: .25rem .5rem;
55-
font-size: .875rem;
56-
border-radius: .2rem;
54+
padding: 0.25rem 0.5rem;
55+
font-size: 0.875rem;
56+
border-radius: 0.2rem;
5757
position: inherit;
5858

5959
&:after {
6060
display: none;
6161
}
6262
}
6363
}
64+
#edit-field-dialogue-proposal-category--wrapper .fieldset-wrapper {
65+
display: flex;
66+
flex-direction: column;
67+
gap: $spacer;
68+
69+
.form-checkboxes {
70+
display: flex;
71+
gap: $spacer;
72+
order: 2;
73+
}
74+
.description {
75+
order: 1;
76+
}
77+
}
6478
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<div class="btn-toggle">
2+
<input class="btn-check" type="checkbox" id="{{ label['#id'] }}" autocomplete="off">
3+
<label class="btn toggle-badge" for="{{ label['#id'] }}">{{ label['#title'] }}</label>
4+
</div>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{#
2+
/**
3+
* @file
4+
* Theme override for a form element.
5+
*
6+
* Available variables:
7+
* - attributes: HTML attributes for the containing element.
8+
* - errors: (optional) Any errors for this form element, may not be set.
9+
* - prefix: (optional) The form element prefix, may not be set.
10+
* - suffix: (optional) The form element suffix, may not be set.
11+
* - required: The required marker, or empty if the associated form element is
12+
* not required.
13+
* - type: The type of the element.
14+
* - name: The name of the element.
15+
* - label: A rendered label element.
16+
* - label_display: Label display setting. It can have these values:
17+
* - before: The label is output before the element. This is the default.
18+
* The label includes the #title and the required marker, if #required.
19+
* - after: The label is output after the element. For example, this is used
20+
* for radio and checkbox #type elements. If the #title is empty but the
21+
* field is #required, the label will contain only the required marker.
22+
* - invisible: Labels are critical for screen readers to enable them to
23+
* properly navigate through forms but can be visually distracting. This
24+
* property hides the label for everyone except screen readers.
25+
* - attribute: Set the title attribute on the element to create a tooltip but
26+
* output no label element. This is supported only for checkboxes and radios
27+
* in \Drupal\Core\Render\Element\CompositeFormElementTrait::preRenderCompositeFormElement().
28+
* It is used where a visual label is not needed, such as a table of
29+
* checkboxes where the row and column provide the context. The tooltip will
30+
* include the title and required marker.
31+
* - description: (optional) A list of description properties containing:
32+
* - content: A description of the form element, may not be set.
33+
* - attributes: (optional) A list of HTML attributes to apply to the
34+
* description content wrapper. Will only be set when description is set.
35+
* - description_display: Description display setting. It can have these values:
36+
* - before: The description is output before the element.
37+
* - after: The description is output after the element. This is the default
38+
* value.
39+
* - invisible: The description is output after the element, hidden visually
40+
* but available to screen readers.
41+
* - disabled: True if the element is disabled.
42+
* - title_display: Title display setting.
43+
*
44+
* @see template_preprocess_form_element()
45+
*/
46+
#}
47+
{% extends 'themes/custom/hoeringsportal/templates/components/toggle-button.html.twig' %}

0 commit comments

Comments
 (0)