Skip to content

feat(button): create stroked and flat button variants #9365

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

Merged
merged 1 commit into from
Feb 1, 2018

Conversation

josephperrott
Copy link
Member

No description provided.

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Jan 12, 2018
@jelbourn jelbourn added the target: minor This PR is targeted for the next minor release label Jan 12, 2018
// Applies styles to buttons with backgrounds: raised, fab, and mini-fab
%mat-raised-button {
// Applies styles to buttons with stroke styling
%mat-stroked-button {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why make stroked and flat sass placeholders? The raised button was a placeholder because the styles applied for both regular raised for fabs.

@include mat-overridable-elevation(2);
@include mat-overridable-elevation(0);

outline: 1px solid currentColor;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be done with border instead of outline? Generally outline should be avoided since things its used by the browser for focus treatment, devtools for element selection, etc.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, it was initially done this way to prevent the border from changing the offset height/width of the button.

@@ -99,6 +99,23 @@
@include _mat-button-ripple-color($theme, default, 0.1);
}

.mat-stroked-button {
color: rgba(0, 0, 0, 0.87);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be pulled from the foreground palette (which accounts for light vs. dark theme)

selector: 'button[mat-flat-button], a[mat-flat-button]',
host: {'class': 'mat-flat-button'}
})
export class MatFlatButtonCssMatStyler {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These separate styler directives aren't really necessary; now would be a good time to do away with them here. You can have MatButton just apply the right class checking the attributes (i.e. adding a new method like _setButtonVariantClass)

Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, we should make the default background for flat buttons the primary color

'[class.mat-raised-button]': `_hasHostAttributes('mat-raised-button')`,
'[class.mat-stroked-button]': `_hasHostAttributes('mat-stroked-button')`,
'[class.mat-mini-fab]': `_hasHostAttributes('mat-mini-fab')`,
'[class.mat-fab]': `_hasHostAttributes('mat-fab')`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit overkill to add 7 bindings when we know that only one of these is going to apply (the bindings will generate more code and incur higher update costs). We only really need to check once at constructor time and add the class manually.

@josephperrott josephperrott force-pushed the button branch 4 times, most recently from 1b11ccd to 245a4f2 Compare January 23, 2018 19:07
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker and removed pr: needs review labels Jan 30, 2018
@josephperrott josephperrott force-pushed the button branch 2 times, most recently from 21dd83b to a863e75 Compare January 31, 2018 04:40
@tinayuangao
Copy link
Contributor

@josephperrott please rebase

@tinayuangao tinayuangao merged commit b652683 into angular:master Feb 1, 2018
mmalerba pushed a commit to mmalerba/components that referenced this pull request Feb 1, 2018
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 8, 2019
@josephperrott josephperrott deleted the button branch March 20, 2020 22:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants