-
Notifications
You must be signed in to change notification settings - Fork 205
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use SixedMixin to manage "size" property
- Loading branch information
Showing
41 changed files
with
1,780 additions
and
351 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
130 changes: 130 additions & 0 deletions
130
packages/action-button/stories/action-button-sizes.stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
/* | ||
Copyright 2020 Adobe. All rights reserved. | ||
This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. You may obtain a copy | ||
of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software distributed under | ||
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
OF ANY KIND, either express or implied. See the License for the specific language | ||
governing permissions and limitations under the License. | ||
*/ | ||
import { html, action } from '@open-wc/demoing-storybook'; | ||
import { TemplateResult } from '@spectrum-web-components/base'; | ||
import '@spectrum-web-components/icon/sp-icon.js'; | ||
import { EditIcon } from '@spectrum-web-components/icons-workflow'; | ||
|
||
import '../src'; | ||
import '../sp-action-button.js'; | ||
|
||
interface Properties { | ||
quiet?: boolean; | ||
disabled?: boolean; | ||
selected?: boolean; | ||
toggles?: boolean; | ||
emphasized?: boolean; | ||
size?: 's' | 'm' | 'l' | 'xl'; | ||
holdAffordance?: boolean; | ||
icon?: TemplateResult; | ||
label?: string; | ||
} | ||
|
||
function renderButton(properties: Properties): TemplateResult { | ||
return html` | ||
<sp-action-button | ||
?quiet="${!!properties.quiet}" | ||
?emphasized="${!!properties.emphasized}" | ||
?disabled=${!!properties.disabled} | ||
?selected=${!!properties.selected} | ||
?toggles=${!!properties.toggles} | ||
@click=${action(`Action`)} | ||
size=${properties.size || 'm'} | ||
?hold-affordance=${!!properties.holdAffordance} | ||
> | ||
${properties.icon}${properties.label} | ||
</sp-action-button> | ||
`; | ||
} | ||
|
||
function renderButtonsSelected(properties: Properties): TemplateResult { | ||
const icon = html` | ||
<sp-icon slot="icon" size=${properties.size || 'm'}> | ||
${EditIcon({ hidden: true })} | ||
</sp-icon> | ||
`; | ||
const label = 'Edit'; | ||
const emphasized = true; | ||
const holdAffordance = true; | ||
const quiet = true; | ||
const disabled = Object.assign({}, properties, { disabled: true }); | ||
const selected = Object.assign({}, properties, { selected: true }); | ||
return html` | ||
<div> | ||
${renderButton({ | ||
...properties, | ||
label, | ||
})} | ||
${renderButton({ | ||
...properties, | ||
label, | ||
icon, | ||
})} | ||
${renderButton({ | ||
...properties, | ||
icon, | ||
})} | ||
${renderButton({ | ||
...properties, | ||
icon, | ||
holdAffordance, | ||
})} | ||
${renderButton({ | ||
...properties, | ||
icon, | ||
quiet, | ||
})} | ||
${renderButton({ | ||
...selected, | ||
icon, | ||
})} | ||
${renderButton({ | ||
...selected, | ||
emphasized, | ||
icon, | ||
})} | ||
${renderButton({ | ||
...disabled, | ||
icon, | ||
})} | ||
</div> | ||
`; | ||
} | ||
|
||
export default { | ||
component: 'sp-action-button', | ||
title: 'Action Button/Sizes', | ||
}; | ||
|
||
export const s = (): TemplateResult => { | ||
return renderButtonsSelected({ | ||
size: 's', | ||
}); | ||
}; | ||
|
||
export const m = (): TemplateResult => { | ||
return renderButtonsSelected({ | ||
size: 'm', | ||
}); | ||
}; | ||
|
||
export const l = (): TemplateResult => { | ||
return renderButtonsSelected({ | ||
size: 'l', | ||
}); | ||
}; | ||
|
||
export const XL = (): TemplateResult => { | ||
return renderButtonsSelected({ | ||
size: 'xl', | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
Copyright 2020 Adobe. All rights reserved. | ||
This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. You may obtain a copy | ||
of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software distributed under | ||
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
OF ANY KIND, either express or implied. See the License for the specific language | ||
governing permissions and limitations under the License. | ||
*/ | ||
|
||
import { html, TemplateResult } from '@spectrum-web-components/base'; | ||
|
||
import '../sp-bar-loader.js'; | ||
|
||
export default { | ||
title: 'Bar Loader/Sizes', | ||
component: 'sp-bar-loader', | ||
}; | ||
|
||
export const s = (): TemplateResult => { | ||
return html` | ||
<sp-bar-loader label="Loading" progress="50" size="s"></sp-bar-loader> | ||
`; | ||
}; | ||
|
||
export const m = (): TemplateResult => { | ||
return html` | ||
<sp-bar-loader label="Loading" progress="50" size="m"></sp-bar-loader> | ||
`; | ||
}; | ||
|
||
export const l = (): TemplateResult => { | ||
return html` | ||
<sp-bar-loader label="Loading" progress="50" size="l"></sp-bar-loader> | ||
`; | ||
}; | ||
|
||
export const XL = (): TemplateResult => { | ||
return html` | ||
<sp-bar-loader label="Loading" progress="50" size="xl"></sp-bar-loader> | ||
`; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
Copyright 2020 Adobe. All rights reserved. | ||
This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. You may obtain a copy | ||
of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software distributed under | ||
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
OF ANY KIND, either express or implied. See the License for the specific language | ||
governing permissions and limitations under the License. | ||
*/ | ||
import { TemplateResult } from '@spectrum-web-components/base'; | ||
import { renderButtonSet } from './index.js'; | ||
|
||
export default { | ||
component: 'sp-button', | ||
title: 'Button/CTA/Sizes', | ||
}; | ||
|
||
const variant = 'cta'; | ||
|
||
export const s = (): TemplateResult => renderButtonSet({ size: 's', variant }); | ||
|
||
export const m = (): TemplateResult => renderButtonSet({ size: 'm', variant }); | ||
|
||
export const l = (): TemplateResult => renderButtonSet({ size: 'l', variant }); | ||
|
||
export const XL = (): TemplateResult => | ||
renderButtonSet({ size: 'xl', variant }); |
Oops, something went wrong.