Skip to content

Commit

Permalink
feat(tooltip): update spectrum css input
Browse files Browse the repository at this point in the history
  • Loading branch information
Westbrook Johnson authored and Westbrook committed Jan 6, 2021
1 parent edf1a4b commit a946b1c
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 20 deletions.
3 changes: 2 additions & 1 deletion packages/tooltip/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"author": "",
"license": "Apache-2.0",
"devDependencies": {
"@spectrum-css/tooltip": "^3.0.0-beta.4"
"@spectrum-css/tooltip": "^3.0.0-beta.5",
"@spectrum-web-components/icons-workflow": "^0.3.6"
},
"dependencies": {
"@spectrum-web-components/base": "^0.1.3",
Expand Down
57 changes: 38 additions & 19 deletions packages/tooltip/stories/tooltip.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,35 @@ import { html, boolean, select, text } from '@open-wc/demoing-storybook';
import '../sp-tooltip.js';
import '@spectrum-web-components/icon/sp-icon';
import '@spectrum-web-components/icons/sp-icons-medium.js';
import { TemplateResult } from '@spectrum-web-components/base';
import { ifDefined, TemplateResult } from '@spectrum-web-components/base';
import {
AlertIcon,
CheckmarkIcon,
InfoIcon,
} from '@spectrum-web-components/icons-workflow';

const tipOptions = ['top', 'bottom', 'left', 'right'];

const variantOptions = ['', 'info', 'positive', 'negative'];

const iconOptions = ['AlertSmall', 'CheckmarkSmall', 'InfoSmall'];
const iconOptions: {
[key: string]: ({
width,
height,
hidden,
title,
}?: {
width?: number;
height?: number;
hidden?: boolean;
title?: string;
}) => TemplateResult | string;
} = {
'': () => html``,
negative: AlertIcon,
positive: CheckmarkIcon,
info: InfoIcon,
};

export default {
component: 'sp-tooltip',
Expand Down Expand Up @@ -50,8 +72,13 @@ export const Default = (): TemplateResult => {
};

export const wIcon = (): TemplateResult => {
const variant = select(
'Variant',
variantOptions,
variantOptions[3],
'Element'
);
return html`
<sp-icons-medium></sp-icons-medium>
<sp-tooltip
?open=${boolean('Open', true, 'Element')}
placement=${select(
Expand All @@ -60,23 +87,15 @@ export const wIcon = (): TemplateResult => {
tipOptions[0],
'Element'
)}
variant=${select(
'Variant',
variantOptions,
variantOptions[0],
'Element'
)}
variant=${ifDefined(variant || undefined)}
>
<sp-icon
size="s"
name="ui:${select(
'Icon',
iconOptions,
iconOptions[0],
'Element'
)}"
slot="icon"
></sp-icon>
${!!variant
? html`
<sp-icon size="none" slot="icon">
${iconOptions[variant]()}
</sp-icon>
`
: html``}
${text('Tip text', 'Tooltip', 'Element')}
</sp-tooltip>
`;
Expand Down

0 comments on commit a946b1c

Please # to comment.