Skip to content

Commit

Permalink
Improve tabs and radio groups (#675)
Browse files Browse the repository at this point in the history
* Tokenize tab slider height and make it 2px by default

* Remove jest-preset-angular dependency

This dependency is not used anymore and has a security vulnerability because of its dependency to an old version of axios.

* Improve radio groups

* Ability to click on the full radio label within radio-group

* Add `noEllipsis` option to radio component
  • Loading branch information
mpellerin42 authored Nov 28, 2023
1 parent c52d35b commit 9060e7b
Show file tree
Hide file tree
Showing 12 changed files with 60 additions and 15 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# 2.63.1 (2023-11-28)

### Improvements

- **Tabs**: tokenize tab slider height, and make it 2px by default
- **RadioGroup**:
- Improve the radio-group style by using flexbox with a gap (default to 8px between each radio, can be overridden using the `$gap-radio-group` token)
- Add a class `horizontal-group` changing the flexbox direction to row
- **Radio**: Add `noEllipsis` option to radio component

### Security

- Remove `jest-preset-angular` dependency, which is not used anymore and has a security vulnerability

# 2.63.0 (2023-11-21)

### Breaking changes
Expand Down
1 change: 0 additions & 1 deletion package-lock.json

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

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
"angular-cli-ghpages": "^1.0.7",
"husky": "^8.0.3",
"jest": "^29.6.2",
"jest-preset-angular": "^13.1.4",
"ng-mocks": "^14.12.1",
"ng-packagr": "^17.0.1",
"prettier": "^3.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,17 @@

<p class="title-xxs">Radio group using formControl</p>
<pa-radio-group
class="horizontal-group"
name="radio-icons"
[formControl]="formControl">
<div style="display: flex">
@for (icon of icons; track icon) {
<div style="display: flex; flex-direction: column; align-items: center; margin-right: 30px">
<pa-icon
size="large"
[name]="icon"></pa-icon>
<pa-radio [value]="icon"></pa-radio>
</div>
}
</div>
@for (icon of icons; track icon) {
<div style="display: flex; flex-direction: column; align-items: center">
<pa-icon
size="large"
[name]="icon"></pa-icon>
<pa-radio [value]="icon"></pa-radio>
</div>
}
</pa-radio-group>
<p>Icon selected: {{ formControl.value }}</p>
<pa-button
Expand Down Expand Up @@ -169,6 +168,17 @@ <h3>Radio group</h3>
<code>{{ paRadioGroup }}</code>. The radio-group will automatically set the name of the
<code>{{ paRadio }}</code> with its own.
</p>
<p>
By default,
<code>{{ paRadioGroup }}</code>
is using flexbox to display the
<code>{{ paRadio }}</code>
aligned in column. Adding the CSS class
<code>horizontal-group</code>
to the
<code>{{ paRadioGroup }}</code>
will change the alignment direction to row.
</p>

<p>
<code>{{ paRadioGroup }}</code>
Expand Down
2 changes: 1 addition & 1 deletion projects/pastanaga-angular/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@guillotinaweb/pastanaga-angular",
"description": "Provides Pastanaga UI elements as Angular components",
"version": "2.63.0",
"version": "2.63.1",
"license": "MIT",
"keywords": [
"angular",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { takeUntil } from 'rxjs/operators';
exportAs: 'paRadioGroup',
host: {
role: 'radiogroup',
style: 'display: block',
class: 'pa-radio-group',
},
})
export class RadioGroupDirective extends PaFormControlDirective implements AfterViewInit, OnDestroy {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
[for]="id"
#label
class="pa-toggle-label"
[class.no-ellipsis]="noEllipsis"
[hidden]="!hasLabel">
<ng-content></ng-content>
</label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class RadioComponent implements AfterContentInit, OnChanges {
@Input({ transform: booleanAttribute }) disabled = false;
@Input({ transform: trimString }) ariaLabel = '';
@Input({ transform: trimString }) help = '';
@Input({ transform: booleanAttribute }) noEllipsis = false;

@Output() change: EventEmitter<{ value: string; checked: boolean }> = new EventEmitter();

Expand Down
18 changes: 18 additions & 0 deletions projects/pastanaga-angular/src/styles/components/_checkbox.scss
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,21 @@
margin-left: rhythm(3.5);
}
}

.pa-radio-group {
display: flex;
flex-direction: column;
gap: $gap-radio-group;

&.horizontal-group {
flex-direction: row;
}

&:not(.horizontal-group) .pa-toggle .pa-checkbox-wrapper {
width: 100%;

.pa-toggle-label {
width: 100%;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
background: $color-tab-slider;
bottom: 0;
content: '';
height: 1px;
height: $height-tab-slider;
left: 0;
position: absolute;
width: 100%;
Expand Down
2 changes: 2 additions & 0 deletions projects/pastanaga-angular/src/styles/theme/_tabs.tokens.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ $font-weight-tab-item-active: $font-weight-bold !default;

$gap-between-tabs: 0 !default;

$height-tab-slider: rhythm(0.25) !default;

$padding-tab-item-small: rhythm(1.5) !default;
$padding-tab-item-medium: rhythm(1.5) !default;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ $color-check-toggle-disabled: $color-neutral-light !default;
// SPACING
//=====================================
$size-toggle-checkbox: calc(#{rhythm(2)} - #{rhythm(0.25)}) !default;
$gap-radio-group: rhythm(1) !default;

//=====================================
// TYPOGRAPHY
Expand Down

0 comments on commit 9060e7b

Please sign in to comment.