-
Notifications
You must be signed in to change notification settings - Fork 6
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
feat(vwc-icon-button): viv-306 layout, shape, connotation support #504
Changes from all commits
2da2d08
791c16f
61ea0e0
61677b7
0e9d8de
3f4c6d5
10723dc
30d15a8
c79ef89
e58f395
2841856
bccaaf5
b111359
1ce01ff
8a52896
544f26a
2fb8fc1
13549e7
03c7fd8
f41e89e
670da52
330b36c
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 |
---|---|---|
|
@@ -13,7 +13,9 @@ export const argTypes = { | |
shape: { | ||
control: { | ||
type: 'select', | ||
options: Object.values(Shape) | ||
options: Object.values(Shape).filter(s => [ | ||
Shape.Rounded, Shape.Pill | ||
].includes(s)), | ||
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. why not just: 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. dunno, it's just more supervised. it follows convention anyway, which is what we encourage, so better if this PR merges as is, and if we change this convention we do it in a dedicated PR |
||
} | ||
}, | ||
layout: { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,9 @@ export const argTypes = { | |
shape: { | ||
control: { | ||
type: 'select', | ||
options: Object.values(Shape), | ||
options: Object.values(Shape).filter(s => [ | ||
Shape.Rounded, Shape.Pill | ||
].includes(s)), | ||
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. same as remark above - why not simple array of white listed values? |
||
} | ||
}, | ||
dense: { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
import '../vwc-button.js'; | ||
import { | ||
textToDomToParent, | ||
isolatedElementsCreation, | ||
|
@@ -7,16 +6,19 @@ import { | |
assertConnotationAttribute, | ||
assertConnotationProperty, | ||
} from '@vonage/vvd-foundation/test/connotation.test.js'; | ||
import { Connotation } from '@vonage/vvd-foundation/constants'; | ||
|
||
const CONNOTATIONS_SUPPORTED = Object.values(Connotation).filter((c) => | ||
[ | ||
Connotation.Primary, | ||
Connotation.CTA, | ||
Connotation.Success, | ||
Connotation.Alert, | ||
Connotation.Info, | ||
Connotation.Announcement, | ||
].includes(c) | ||
); | ||
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. same as above - why not a simple array? |
||
|
||
const VWC_BUTTON = 'vwc-button'; | ||
const CONNOTATIONS_SUPPORTED = [ | ||
'primary', | ||
'cta', | ||
'success', | ||
'alert', | ||
'info', | ||
'announcement', | ||
]; | ||
const LAYOUTS_AFFECTED = [ | ||
{ | ||
layout: 'filled', | ||
|
@@ -36,15 +38,17 @@ const LAYOUTS_AFFECTED = [ | |
}, | ||
]; | ||
|
||
describe('button connotation', () => { | ||
export async function connotationTestCases(COMPONENT_NAME) { | ||
const addElement = isolatedElementsCreation(); | ||
|
||
for (const { layout, childrenAffected, stylesAffected } of LAYOUTS_AFFECTED) { | ||
for (const connotation of CONNOTATIONS_SUPPORTED) { | ||
it(`should reflect '${connotation}' connotation (attribute) visually, ${layout}`, async () => { | ||
const [button] = addElement( | ||
textToDomToParent( | ||
`<${VWC_BUTTON} layout="${layout}">Button</${VWC_BUTTON}>` | ||
`<${COMPONENT_NAME} layout="${layout}" icon="bin"> | ||
${COMPONENT_NAME === 'vwc-button' ? 'Button' : ''} | ||
</${COMPONENT_NAME}>` | ||
) | ||
); | ||
await assertConnotationAttribute({ | ||
|
@@ -58,7 +62,9 @@ describe('button connotation', () => { | |
it(`should reflect '${connotation}' connotation (property) visually, ${layout}`, async () => { | ||
const [button] = addElement( | ||
textToDomToParent( | ||
`<${VWC_BUTTON} layout="${layout}">Button</${VWC_BUTTON}>` | ||
`<${COMPONENT_NAME} layout="${layout}" icon="bin"> | ||
${COMPONENT_NAME === 'vwc-button' ? 'Button' : ''} | ||
</${COMPONENT_NAME}>` | ||
) | ||
); | ||
await assertConnotationProperty({ | ||
|
@@ -70,4 +76,4 @@ describe('button connotation', () => { | |
}); | ||
} | ||
} | ||
}); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,52 @@ | ||
@use '@vonage/vvd-design-tokens/build/scss/semantic-variables/scheme-variables'; | ||
@use '@vonage/vvd-foundation/scss/variable-names/color-semantic-variable-names' as color-semantic; | ||
@use '@vonage/vvd-foundation/scss/mixins/shape-mixins'; | ||
@use '@vonage/vvd-foundation/scss/mixins/color-connotation-mixins' with ( | ||
$connotations: primary cta success alert info announcement | ||
); | ||
@use '@vonage/vvd-foundation/scss/mixins/layout-mixins' with ( | ||
$layouts: filled outlined ghost | ||
); | ||
|
||
:host { | ||
.mdc-icon-button { | ||
background-color: var(--background-color); | ||
border: var(--border); | ||
border-radius: var(--border-radius); | ||
color: var(--color); | ||
display: inline-flex; | ||
align-items: center; | ||
justify-content: center; | ||
overflow: hidden; | ||
} | ||
|
||
.vwc-icon { | ||
--size: 20px; | ||
height: var(--size); | ||
width: var(--size); | ||
} | ||
} | ||
|
||
// theming | ||
:host { | ||
.mdc-icon-button { | ||
color: var(#{scheme-variables.$vvd-color-on-base}); | ||
@include color-connotation-mixins.connotations-context( | ||
':host([layout="filled"]#{color-connotation-mixins.$connotation-placeholder}),:host([layout="outlined"]#{color-connotation-mixins.$connotation-placeholder})' | ||
); | ||
|
||
:host([layout='filled']) { | ||
.mdc-icon-button:disabled { | ||
background-color: var(#{scheme-variables.$vvd-color-contrast-soft}); | ||
} | ||
} | ||
|
||
:host([layout='outlined']) { | ||
.mdc-icon-button:disabled { | ||
border-color: var(#{color-semantic.$formfield-disabled-ink}); | ||
} | ||
} | ||
|
||
:host { | ||
.mdc-icon-button:disabled { | ||
color: var( #{color-semantic.$formfield-disabled-ink}); | ||
color: var(#{color-semantic.$formfield-disabled-ink}); | ||
} | ||
} | ||
|
||
|
@@ -27,8 +57,25 @@ | |
|
||
:host([dense]) { | ||
--mdc-icon-button-size: 32px; | ||
|
||
.vwc-icon { | ||
--size: 16px; | ||
} | ||
} | ||
|
||
:host([enlarged]) { | ||
--mdc-icon-button-size: 48px; | ||
|
||
.vwc-icon { | ||
--size: 24px; | ||
} | ||
} | ||
|
||
@include shape-mixins.shape( | ||
$shapes: ( | ||
rounded: 6px, | ||
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. rounded is 6px by default. can we exclude this from override somehow? |
||
circled: 50%, | ||
) | ||
); | ||
|
||
@include layout-mixins.layout(); |
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.
what's the difference between text & ghost?
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.
text and ghost styles are the same.
I didn't think layout="text" was appropriate for icon-button as there is no text in this element.
What do you think?
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.
Then remove the text
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.
Is anyone using layout="text" buttons?
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.
I'll check, if so, we can keep both as css selectors for backwards compatibility
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.
maybe late to the party, but:
vwc-icon-button
which is text-less, as @JoelGraham93 mentioned,ghost
sounds bettertransparent
is even better thanghost
?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.
hmmm, if had to pick, I would 'ghost'. but am up for more ideas on that
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.
I'm happy with ghost as it's a common term for buttons with no fill colour - though they usually have a border.
Was there any discoveries about removing layout="text"? I see PR is labeled
ready-to-merge