-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(arch): move && simplify component tooltip
- Loading branch information
Showing
108 changed files
with
442 additions
and
496 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
134 changes: 134 additions & 0 deletions
134
packages-new/components/tooltip/documentation/specifications/spec.md
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,134 @@ | ||
* [**Interfaces**](#interfaces) | ||
* [**Types**](#types) | ||
* [**Classes**](#classes) | ||
* [**Type alias**](#type-alias) | ||
* [**Variables**](#variables) | ||
|
||
## Interfaces | ||
|
||
### OdsTooltipAttributes | ||
|name | Type | Required | Default | Description| | ||
|---|---|:---:|---|---| | ||
|**`variant`** | `OdsTooltipVariant` | | | with or without visible tip: see component principles| | ||
|
||
### OdsTooltipBehavior | ||
|name | Type | Required | Default | Description| | ||
|---|---|:---:|---|---| | ||
|**`anchor`** | `HTMLDivElement` | ✴️ | | | | ||
|**`el`** | `HTMLStencilElement` | ✴️ | | | | ||
|**`surface`** | `undefined` \| `OcdkSurface` | ✴️ | | | | ||
|**`checkForClickOutside`** | _void_ | ✴️ | | | | ||
|**`handleMouseEnter`** | _void_ | ✴️ | | | | ||
|**`handleMouseLeave`** | _void_ | ✴️ | | | | ||
|**`handleTriggerBlur`** | _void_ | ✴️ | | | | ||
|**`handleTriggerClick`** | _void_ | ✴️ | | | | ||
|**`handleTriggerFocus`** | _void_ | ✴️ | | | | ||
|**`syncReferences`** | _void_ | ✴️ | | | | ||
|
||
### OdsTooltipMethods | ||
|name | Type | Required | Default | Description| | ||
|---|---|:---:|---|---| | ||
|**`closeSurface`** | _void_ | ✴️ | | Close the surface| | ||
|**`setTabindex`** | _void_ | ✴️ | | set tab index on the component| | ||
|
||
## Types | ||
|
||
### OdsTooltipVariant | ||
| | | ||
|:---:| | ||
| `standard` | | ||
| `tip` | | ||
|
||
## Classes | ||
|
||
### OdsTooltipContentController | ||
_common controller logic for component used by the different implementations._ | ||
_it contains all the glue between framework implementation and the third party service._ | ||
|
||
|
||
### OdsTooltipController | ||
_common controller logic for component used by the different implementations._ | ||
_it contains all the glue between framework implementation and the third party service._ | ||
|
||
#### Methods | ||
> **checkForClickOutside**() => _unknown_ | ||
|
||
> **closeSurface**() => _unknown_ | ||
|
||
> **handleMouseEnter**() => _unknown_ | ||
|
||
> **handleMouseLeave**() => _unknown_ | ||
|
||
> **handleTriggerBlur**() => _unknown_ | ||
|
||
> **handleTriggerClick**() => _unknown_ | ||
|
||
> **handleTriggerFocus**() => _unknown_ | ||
|
||
> **syncReferences**() => _unknown_ | ||
|
||
> **validateAttributes**() => _unknown_ | ||
|
||
|
||
## Type alias | ||
|
||
### OdsTooltip | ||
|
||
interface description of all implementation of `ods-tooltip`. | ||
each implementation must have defined events, methods, attributes | ||
and one controller for the common behavior logic | ||
|
||
> - `OdsComponentGenericMethods` | ||
> - `OdsComponentGenericEvents` | ||
### OdsTooltipContent | ||
|
||
interface description of all implementation of `ods-tooltip-content`. | ||
each implementation must have defined events, methods, attributes | ||
and one controller for the common behavior logic | ||
|
||
> - `OdsComponentGenericMethods` | ||
> - `OdsComponentGenericEvents` | ||
### OdsTooltipAttributes | ||
|
||
> _Based on `OdsComponentAttributes`_ | ||
### OdsTooltipContentAttributes | ||
|
||
> _Based on `OdsComponentAttributes`_ | ||
### OdsTooltipContentEvents | ||
|
||
> _Based on `OdsComponentEvents`_ | ||
### OdsTooltipContentMethods | ||
|
||
> _Based on `OdsComponentMethods`_ | ||
### OdsTooltipEvents | ||
|
||
> _Based on `OdsComponentEvents`_ | ||
### OdsTooltipMethods | ||
|
||
> _Based on `OdsComponentMethods`_ | ||
## Variables | ||
|
||
### odsTooltipContentDefaultAttributes | ||
`OdsTooltipContentAttributes` | ||
|
||
### odsTooltipDefaultAttributes | ||
`OdsTooltipAttributes` |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 1 addition & 2 deletions
3
...onents/tooltip/specifications-tooltip.mdx → ...specifications/specifications-tooltip.mdx
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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
import { Description } from '@storybook/addon-docs'; | ||
|
||
import Specs from '@ovhcloud/ods-core/src/components/tooltip/docs/spec.md'; | ||
import Specs from './spec.md'; | ||
|
||
<Description>{ Specs }</Description> |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
29 changes: 29 additions & 0 deletions
29
...es-new/components/tooltip/src/components/osds-tooltip-content/osds-tooltip-content.e2e.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,29 @@ | ||
import type { E2EElement, E2EPage } from '@stencil/core/testing'; | ||
import { newE2EPage } from '@stencil/core/testing'; | ||
|
||
describe('e2e:osds-tooltip-content', () => { | ||
let page: E2EPage; | ||
let el: E2EElement; | ||
|
||
async function setup({ html }: { html?: string } = {}) { | ||
page = await newE2EPage(); | ||
await page.setContent(`<osds-tooltip-content>${html}</osds-tooltip-content>`); | ||
await page.evaluate(() => document.body.style.setProperty('margin', '0px')); | ||
|
||
el = await page.find('osds-tooltip-content'); | ||
} | ||
|
||
it('should render', async () => { | ||
await setup(); | ||
expect(el).not.toBeNull(); | ||
expect(el).toHaveClass('hydrated'); | ||
}); | ||
|
||
describe('default slot', () => { | ||
it('should display a text', async () => { | ||
const slot = '<span>Dummy text</span>' | ||
await setup({ html: slot }); | ||
expect(el.innerHTML).toBe(slot); | ||
}) | ||
}); | ||
}); |
File renamed without changes.
29 changes: 29 additions & 0 deletions
29
...s-new/components/tooltip/src/components/osds-tooltip-content/osds-tooltip-content.spec.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,29 @@ | ||
import type { SpecPage } from '@stencil/core/testing'; | ||
import { newSpecPage } from '@stencil/core/testing'; | ||
import { OsdsTooltipContent } from './osds-tooltip-content'; | ||
|
||
describe('spec:osds-tooltip-content', () => { | ||
let page: SpecPage; | ||
let root: HTMLElement | undefined; | ||
let instance: OsdsTooltipContent; | ||
|
||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
async function setup() { | ||
page = await newSpecPage({ | ||
components: [OsdsTooltipContent], | ||
html: `<osds-tooltip-content>My Tooltip Content</osds-tooltip-content>`, | ||
}); | ||
|
||
root = page.root; | ||
instance = page.rootInstance; | ||
} | ||
|
||
it('should render', async () => { | ||
await setup(); | ||
expect(root?.shadowRoot).toBeTruthy(); | ||
expect(instance).toBeTruthy(); | ||
}); | ||
}); |
21 changes: 21 additions & 0 deletions
21
packages-new/components/tooltip/src/components/osds-tooltip-content/osds-tooltip-content.tsx
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,21 @@ | ||
import { Component, Element, Host, h } from '@stencil/core'; | ||
|
||
/** | ||
* @slot (tooltip-content) - The Tooltip content | ||
*/ | ||
@Component({ | ||
tag: 'osds-tooltip-content', | ||
styleUrl: 'osds-tooltip-content.scss', | ||
shadow: true | ||
}) | ||
export class OsdsTooltipContent { | ||
@Element() el!: HTMLElement; | ||
|
||
render() { | ||
return ( | ||
<Host> | ||
<slot></slot> | ||
</Host> | ||
); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
packages-new/components/tooltip/src/components/osds-tooltip-content/public-api.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 @@ | ||
export { OsdsTooltipContent } from './osds-tooltip-content'; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 10 additions & 0 deletions
10
packages-new/components/tooltip/src/components/osds-tooltip/constants/default-attributes.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,10 @@ | ||
import type { OdsTooltipAttribute } from '../interfaces/attributes'; | ||
import { ODS_TOOLTIP_VARIANT } from './tooltip-variant'; | ||
|
||
const DEFAULT_ATTRIBUTE: OdsTooltipAttribute = Object.freeze({ | ||
variant: ODS_TOOLTIP_VARIANT.standard, | ||
}); | ||
|
||
export { | ||
DEFAULT_ATTRIBUTE, | ||
}; |
11 changes: 11 additions & 0 deletions
11
packages-new/components/tooltip/src/components/osds-tooltip/constants/tooltip-variant.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,11 @@ | ||
enum ODS_TOOLTIP_VARIANT { | ||
standard = 'standard', | ||
tip = 'tip', | ||
} | ||
|
||
const ODS_TOOLTIP_VARIANTS = Object.freeze(Object.values(ODS_TOOLTIP_VARIANT)); | ||
|
||
export { | ||
ODS_TOOLTIP_VARIANT, | ||
ODS_TOOLTIP_VARIANTS, | ||
}; |
Oops, something went wrong.