mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-19 14:09:20 -04:00
- Removed links to the gov uk stylesheets
- Deleted /stylesheets folder - Removed sass build from gulpfile - Changed gov links to usa links - Changed other govuk styles, like breadcrumbs - Changed name of uk_components file to us_components - Fixed a few tests that broke on account of the changes
This commit is contained in:
15
app/templates/components/us_components/label/README.md
Normal file
15
app/templates/components/us_components/label/README.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# Label
|
||||
|
||||
## Installation
|
||||
|
||||
See the [main README quick start guide](https://github.com/alphagov/govuk-frontend#quick-start) for how to install this component.
|
||||
|
||||
## Guidance and Examples
|
||||
|
||||
The label component is used in other input components, to see an example of it in use see the [text input component](https://design-system.service.gov.uk/components/text-input/).
|
||||
|
||||
## Component options
|
||||
|
||||
Use options to customize the appearance, content and behavior of a component when using a macro, for example, changing the text.
|
||||
|
||||
See [options table](https://design-system.service.gov.uk/components/file-upload/#options-example-default--label) for details.
|
||||
45
app/templates/components/us_components/label/_label.scss
Normal file
45
app/templates/components/us_components/label/_label.scss
Normal file
@@ -0,0 +1,45 @@
|
||||
@import "../../settings/all";
|
||||
@import "../../tools/all";
|
||||
@import "../../helpers/all";
|
||||
|
||||
@include govuk-exports("govuk/component/label") {
|
||||
.govuk-label {
|
||||
@include govuk-font($size: 19);
|
||||
@include govuk-text-colour;
|
||||
|
||||
display: block;
|
||||
|
||||
margin-bottom: govuk-spacing(1);
|
||||
}
|
||||
|
||||
// Modifiers that make labels look more like their equivalent headings
|
||||
|
||||
.govuk-label--xl {
|
||||
@include govuk-font($size: 48, $weight: bold);
|
||||
margin-bottom: govuk-spacing(3);
|
||||
}
|
||||
|
||||
.govuk-label--l {
|
||||
@include govuk-font($size: 36, $weight: bold);
|
||||
margin-bottom: govuk-spacing(3);
|
||||
}
|
||||
|
||||
.govuk-label--m {
|
||||
@include govuk-font($size: 24, $weight: bold);
|
||||
margin-bottom: govuk-spacing(2);
|
||||
}
|
||||
|
||||
.govuk-label--s {
|
||||
@include govuk-font($size: 19, $weight: bold);
|
||||
}
|
||||
|
||||
// When the label is nested inside a heading, override the heading so that it
|
||||
// does not have a margin. Effectively we want to be able to treat the heading
|
||||
// as if it is not there.
|
||||
//
|
||||
// This breaks BEM conventions because it exists as a parent of the 'block',
|
||||
// so we can't really consider an element.
|
||||
.govuk-label-wrapper {
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
[
|
||||
{
|
||||
"name": "text",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"description": "If `html` is set, this is not required. Text to use within the label. If `html` is provided, the `text` argument will be ignored."
|
||||
},
|
||||
{
|
||||
"name": "html",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"description": "If `text` is set, this is not required. HTML to use within the label. If `html` is provided, the `text` argument will be ignored."
|
||||
},
|
||||
{
|
||||
"name": "for",
|
||||
"type": "string",
|
||||
"required": true,
|
||||
"description": "The value of the for attribute, the id of the input the label is associated with."
|
||||
},
|
||||
{
|
||||
"name": "isPageHeading",
|
||||
"type": "boolean",
|
||||
"required": false,
|
||||
"description": "Whether the label also acts as the heading for the page."
|
||||
},
|
||||
{
|
||||
"name": "classes",
|
||||
"type": "string",
|
||||
"required": false,
|
||||
"description": "Classes to add to the label tag."
|
||||
},
|
||||
{
|
||||
"name": "attributes",
|
||||
"type": "object",
|
||||
"required": false,
|
||||
"description": "HTML attributes (for example data attributes) to add to the label tag."
|
||||
}
|
||||
]
|
||||
3
app/templates/components/us_components/label/macro.njk
Normal file
3
app/templates/components/us_components/label/macro.njk
Normal file
@@ -0,0 +1,3 @@
|
||||
{% macro govukLabel(params) %}
|
||||
{%- include "./template.njk" -%}
|
||||
{% endmacro %}
|
||||
15
app/templates/components/us_components/label/template.njk
Normal file
15
app/templates/components/us_components/label/template.njk
Normal file
@@ -0,0 +1,15 @@
|
||||
{% if params.html or params.text %}
|
||||
{% set labelHtml %}
|
||||
<label class="usa-label{%- if params.classes %} {{ params.classes }}{% endif %}"
|
||||
{%- for attribute, value in params.attributes %} {{attribute}}="{{value}}"{% endfor %}
|
||||
{%- if params.for %} for="{{ params.for }}"{% endif %}>
|
||||
{{ params.html | safe if params.html else params.text }}
|
||||
</label>
|
||||
{% endset %}
|
||||
|
||||
{% if params.isPageHeading %}
|
||||
<h1 class="govuk-label-wrapper">{{ labelHtml | safe | indent(2) }}</h1>
|
||||
{% else %}
|
||||
{{ labelHtml | safe }}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
Reference in New Issue
Block a user