Skip to content

Commit

Permalink
Complete Default Styling tooltip (#309)
Browse files Browse the repository at this point in the history
  • Loading branch information
aidendk committed Jun 16, 2022
1 parent 0e71240 commit 46274eb
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 21 deletions.
23 changes: 15 additions & 8 deletions packages/nimble-components/src/tooltip/styles.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
import { css } from '@microsoft/fast-element';
import { display } from '@microsoft/fast-foundation';
import {
borderColor,
BannerFail100DarkUi,
Black15,
Information100LightUi,
White
} from '@ni/nimble-tokens/dist/styledictionary/js/tokens';
import {
borderRgbPartialColor,
tooltipCaptionFont,
tooltipCaptionFontColor,
borderWidth,
popupBoxShadowColor
} from '../theme-provider/design-tokens';
import { TooltipStatus } from './types';

// font should be source sans pro regular 11px
// shadow color???
// box shadow color may need to be fixed
// purple color needs to be fixed

export const styles = css`
${display('inline-flex')}
:host {
font: ${tooltipCaptionFont};
font: ${tooltipCaptionFont};
color: ${tooltipCaptionFontColor};
align-items: left;
cursor: pointer;
Expand All @@ -26,9 +33,9 @@ export const styles = css`
.tooltip {
box-sizing: border-box;
flex-shrink: 0;
border: ${borderWidth} solid ${borderColor};
box-shadow: ${popupBoxShadowColor};
background: #00000029;
border: ${borderWidth} solid rgba(${borderRgbPartialColor}, 0.3);
box-shadow: 0px 3px 4px #00000029;
background-color: ${Black15};
padding: 1px;
display: inline-flex;
align-items: center;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const verticalViewportLockStates = [
] as const;
type VerticalViewportLockState = typeof verticalViewportLockStates[number];

// WIP need to figure out anchoring
// WIP need to figure out anchoring- They all have the same ids and anchors- only first button tooltip works

const component = (
[horiontalViewportLockName, horiontalViewportLock]: HoriontalViewportLockState,
Expand All @@ -50,6 +50,7 @@ id="anchor">${horiontalViewportLockName} ${verticalViewportLockName}
<nimble-tooltip
anchor='anchor'
visible
?horiontalViewportLock="${() => horiontalViewportLock}"
?verticalViewportLock="${() => verticalViewportLock}"
>
Expand Down
37 changes: 25 additions & 12 deletions packages/nimble-components/src/tooltip/tests/tooltip.stories.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import { html } from '@microsoft/fast-element';
import type { Meta, StoryObj } from '@storybook/html';
import { withXD } from 'storybook-addon-xd-designs';
import type { AutoUpdateMode } from '@microsoft/fast-foundation';
import { createUserSelectedThemeStory } from '../../utilities/tests/storybook';
import '../../all-components';
import { TooltipStatus } from '../types';

interface TooltipArgs {
// Auto update mode?
delay: number;
horiontalViewportLock: boolean;
verticalViewportLock: boolean;
tooltip: string;
status: TooltipStatus;
autoUpdateMode: AutoUpdateMode; // Need to figure out how to test / make sure this works?
// anchorIdSet: string; // maybe do this?
}

const metadata: Meta<TooltipArgs> = {
Expand All @@ -31,24 +35,33 @@ const metadata: Meta<TooltipArgs> = {
}
},
render: createUserSelectedThemeStory(html<TooltipArgs>`
<nimble-button id="anchor">text</nimble-button>
<nimble-button id='anchor'>text</nimble-button>
<nimble-tooltip
anchor='anchor'
delay='${x => x.delay}'
?horiontalViewportLock="${x => x.horiontalViewportLock}"
?verticalViewportLock="${x => x.verticalViewportLock}"
>
${x => x.tooltip}
</nimble-tooltip>
<nimble-tooltip
anchor='anchor'
delay='${x => x.delay}'
?horiontalViewportLock="${x => x.horiontalViewportLock}"
?verticalViewportLock="${x => x.verticalViewportLock}"
autoUpdateMode='anchor'
>
${x => x.tooltip}
</nimble-tooltip>
`),
args: {
tooltip: 'Tooltip label',
delay: 300,
horiontalViewportLock: false,
verticalViewportLock: false
}
verticalViewportLock: false,
status: TooltipStatus.default
},
argTypes: {
status: {
options: Object.values(TooltipStatus),
control: { type: 'radio' },
}
},
};

export default metadata;

export const tooltip: StoryObj<TooltipArgs> = {};
10 changes: 10 additions & 0 deletions packages/nimble-components/src/tooltip/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* Predefined icon status states
* @public
*/
export const TooltipStatus = {
default: 'default',
error: 'error',
information: 'information',
} as const;
export type TooltipStatus = typeof TooltipStatus[keyof typeof TooltipStatus];

0 comments on commit 46274eb

Please sign in to comment.