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

fix(bal-field, bal-hint): ensure proper alignment of field hint by ad… #1229

Merged
merged 10 commits into from
Jan 23, 2024
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
5 changes: 5 additions & 0 deletions .changeset/curly-pots-drop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@baloise/design-system-components': patch
---

Ensure proper alignment of field hint by adjusting its position to the end of the label text.
11 changes: 8 additions & 3 deletions packages/components/src/components/bal-field/bal-field.sass
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
font-family: var(--bal-font-family-text)

+block(field-label)
display: inline-block
margin-bottom: .25rem
display: inline

.bal-field-label ~ .bal-field-control
margin-top: .25rem

+block(field-hint)
display: inline-block
Expand Down Expand Up @@ -79,5 +81,8 @@
.bal-hint
top: 0

.bal-field-hint ~ .bal-field-message
.bal-field-hint ~ .bal-field-message
margin-left: calc(var(--bal-field-label-horizontal-width) + (var(--bal-field-label-column-gap) * 2) + 1.125rem)

.bal-field-label ~ .bal-field-control
margin-top: 0
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,21 @@
<bal-field-message color="danger">Required Field</bal-field-message>
</bal-field>
</section>
<section data-testid="label-long-with-hint" style="width: 200px">
<bal-field>
<bal-field-label
>This is a very long label to test if the hint will be at the end of the text when it
breaks</bal-field-label
>
<bal-field-hint subject="Spider-Man">
Spider-Man is a fictional superhero created by writer-editor Stan Lee and writer-artist Steve Ditko.
</bal-field-hint>
<bal-field-control>
<bal-input placeholder="Basic"></bal-input>
</bal-field-control>
<bal-field-message color="hint">Field Message</bal-field-message>
</bal-field>
</section>
</main>
</bal-doc-app>
</body>
Expand Down
3 changes: 3 additions & 0 deletions test/cypress/e2e/visual/bal-field.visual.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ describe('bal-field', () => {
cy.getByTestId('required').compareSnapshot('field-required-desktop')
cy.getByTestId('valid').compareSnapshot('field-valid-desktop')
cy.getByTestId('label-long').compareSnapshot('label-long-desktop')
cy.getByTestId('label-long-with-hint').compareSnapshot('label-long-with-hint-desktop')

cy.platform('tablet')
cy.getByTestId('basic').compareSnapshot('field-basic-tablet')
Expand All @@ -19,6 +20,7 @@ describe('bal-field', () => {
cy.getByTestId('required').compareSnapshot('field-required-tablet')
cy.getByTestId('valid').compareSnapshot('field-valid-tablet')
cy.getByTestId('label-long').compareSnapshot('label-long-tablet')
cy.getByTestId('label-long-with-hint').compareSnapshot('label-long-with-hint-tablet')

cy.platform('mobile')
cy.getByTestId('basic').compareSnapshot('field-basic-mobile')
Expand All @@ -28,6 +30,7 @@ describe('bal-field', () => {
cy.getByTestId('required').compareSnapshot('field-required-mobile')
cy.getByTestId('valid').compareSnapshot('field-valid-mobile')
cy.getByTestId('label-long').compareSnapshot('label-long-mobile')
cy.getByTestId('label-long-with-hint').compareSnapshot('label-long-with-hint-mobile')
})
})

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.