-
Notifications
You must be signed in to change notification settings - Fork 2
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
Icon button variations #898
base: apps.humanatlas.io
Are you sure you want to change the base?
Changes from 13 commits
d48a66e
f537a17
238a788
d4f95ae
b841d2b
5e454bc
d7d829a
de89fac
503911a
c4c70fd
be22f17
8787bd0
e1936b2
bebaa14
5a80647
69f68b1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './lib/icon-button-size/icon-button-size.directive'; | ||
export * from './lib/icon-button-variant/icon-button-variant.directive'; | ||
export * from './lib/providers'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,31 @@ | ||
button[mat-icon-button] { | ||
button[mat-icon-button], | ||
a[mat-icon-button] { | ||
--mat-icon-button-hover-state-layer-opacity: 0.08; | ||
--mat-icon-button-pressed-state-layer-opacity: 0.16; | ||
--mat-icon-button-state-layer-color: var(--sys-secondary); | ||
--mat-icon-button-focus-state-layer-opacity: 0; | ||
--mdc-icon-button-icon-color: var(--sys-on-tertiary-fixed); | ||
|
||
&:focus-visible { | ||
outline: 2px solid var(--sys-tertiary); | ||
--mdc-icon-button-icon-color: var(--sys-secondary); | ||
border: 2px solid var(--sys-tertiary); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please change back to using outline. Using border causes a layout shift making the icon move slightly |
||
mat-icon { | ||
left: -2px; | ||
top: -2px; | ||
} | ||
} | ||
|
||
mat-icon { | ||
height: var(--mdc-icon-button-icon-size); | ||
width: var(--mdc-icon-button-icon-size); | ||
font-size: var(--mdc-icon-button-icon-size); | ||
} | ||
|
||
&.icon-button-variant-light { | ||
--mdc-icon-button-icon-color: var(--sys-on-primary); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The ripple colors need to be changed to match the spec |
||
} | ||
|
||
&.icon-button-variant-dark { | ||
--mdc-icon-button-icon-color: var(--sys-secondary); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Directive, input } from '@angular/core'; | ||
|
||
/** Input options for icon button color */ | ||
export type IconButtonVariant = 'light' | 'dark' | 'default'; | ||
|
||
/** | ||
* Directive for icon button variants (color) | ||
*/ | ||
@Directive({ | ||
selector: '[hraIconButtonVariant]', | ||
standalone: true, | ||
host: { | ||
'[class]': '"icon-button-variant-" + variant()', | ||
}, | ||
}) | ||
export class IconButtonVariantDirective { | ||
/** Input for icon button color variant */ | ||
readonly variant = input<IconButtonVariant>('default', { alias: 'hraIconButtonVariant' }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's change the default value to dark. It seems to be the most commonly used version across the apps. Let's also change the string |
||
} |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add stories show casing the different variants |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,14 @@ | ||
<a [href]="link()" target="_blank" rel="noopener noreferrer"> | ||
<a | ||
mat-icon-button | ||
[hraIconButtonVariant]="variant()" | ||
[hraIconButtonSize]="size()" | ||
[href]="link()" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
@if (name() === 'email') { | ||
<mat-icon [class.small]="size() === 'small'">email</mat-icon> | ||
<mat-icon>email</mat-icon> | ||
} @else { | ||
<mat-icon [class.small]="size() === 'small'" [svgIcon]="icon()"></mat-icon> | ||
<mat-icon [svgIcon]="icon()"></mat-icon> | ||
} | ||
</a> |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
import { CommonModule } from '@angular/common'; | ||
import { ChangeDetectionStrategy, Component, computed, input } from '@angular/core'; | ||
import { MatButtonModule } from '@angular/material/button'; | ||
import { MatIconModule } from '@angular/material/icon'; | ||
import { | ||
IconButtonSize, | ||
IconButtonSizeDirective, | ||
IconButtonVariant, | ||
IconButtonVariantDirective, | ||
} from '@hra-ui/design-system/icon-button'; | ||
|
||
/** Social media name type */ | ||
export type SocialMediaName = 'x' | 'facebook' | 'instagram' | 'youtube' | 'linkedin' | 'email' | 'github'; | ||
/** Button size type */ | ||
export type SocialMediaButtonSize = 'small' | 'large'; | ||
|
||
/** All CNS links */ | ||
export const SOCIAL_LINKS: Record<SocialMediaName, string> = { | ||
|
@@ -14,8 +19,8 @@ export const SOCIAL_LINKS: Record<SocialMediaName, string> = { | |
instagram: 'https://www.instagram.com/cns_at_iu/', | ||
youtube: 'https://www.youtube.com/@CNSCenter/', | ||
linkedin: 'https://www.linkedin.com/company/cns-indiana-university-bloomington', | ||
email: 'mailto:[email protected]', | ||
github: 'https://github.com/hubmapconsortium/hra-ui', | ||
email: 'mailto:[email protected]', | ||
}; | ||
|
||
/** | ||
|
@@ -24,17 +29,19 @@ export const SOCIAL_LINKS: Record<SocialMediaName, string> = { | |
@Component({ | ||
selector: 'hra-social-media-button', | ||
standalone: true, | ||
imports: [CommonModule, MatIconModule], | ||
imports: [CommonModule, MatButtonModule, MatIconModule, IconButtonVariantDirective, IconButtonSizeDirective], | ||
templateUrl: './social-media-button.component.html', | ||
styleUrl: './social-media-button.component.scss', | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class SocialMediaButtonComponent { | ||
/** Button name */ | ||
readonly name = input.required<SocialMediaName>(); | ||
|
||
/** Button size */ | ||
readonly size = input.required<SocialMediaButtonSize>(); | ||
readonly size = input<IconButtonSize>('large'); | ||
|
||
/** Button variant */ | ||
readonly variant = input<IconButtonVariant>('default'); | ||
|
||
/** Icon to display */ | ||
protected icon = computed(() => `social:${this.name()}`); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put this entire block after the variant selectors at line 30 to give it higher priority. Currently the icon color does not change when focused