Skip to content

Commit

Permalink
feat(flag): migrate to new archi
Browse files Browse the repository at this point in the history
  • Loading branch information
skhamvon authored and dpellier committed Aug 16, 2023
1 parent e310c7d commit 5e0ea78
Show file tree
Hide file tree
Showing 79 changed files with 386 additions and 487 deletions.
2 changes: 2 additions & 0 deletions packages-new/common/core/src/content/public-api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './ods-load-content';
export * from './ods-svg-validator';
1 change: 1 addition & 0 deletions packages-new/common/core/src/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/
export * from './a11y/public-api';
export * from './components/public-api';
export * from './content/public-api';
export * from './configure/public-api';
export * from './element/public-api';
export * from './form/public-api';
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
74 changes: 74 additions & 0 deletions packages-new/components/flag/documentation/specifications/spec.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
* [**Interfaces**](#interfaces)
* [**Classes**](#classes)
* [**Type alias**](#type-alias)
* [**Variables**](#variables)

## Interfaces

### OdsFlagAttributes
|name | Type | Required | Default | Description|
|---|---|:---:|---|---|
|**`assetPath`** | `undefined` \| `string` | ✴️ | | override the `ODS` directory path of the assets.if not set, the configured path in `ODS` will be used.|
|**`iso`** | `undefined` \| `ODS_COUNTRY_ISO_CODE` | ✴️ | | Flag ISO country code|
|**`lazy`** | _boolean_ | ✴️ | | allow to lazy load the content only when it's visible|
|**`src`** | `undefined` \| `string` | ✴️ | | override with custom src to the svg file.|

### OdsFlagBehavior
|name | Type | Required | Default | Description|
|---|---|:---:|---|---|
|**`hostElement`** | `Host` | ✴️ | | reference to the host element of the component|
|**`getAssetPath`** | _string_ | ✴️ | | get the asset directory path in witch the content is serve.could be like `build/` or empty.in addition, the `ODS` asset path will be used.|
|**`load`** | _void_ | ✴️ | | trigger the content load.should be triggered when `iso`, `assetPath` and `src` attributes changed.should call controller's method `load` and change the svg content with the one received.should define the `aria-label` to use with `iso` code.|
|**`onDestroy`** | _void_ | ✴️ | | clean up thing.should call controller's method `onDestroy`|
|**`onInit`** | _void_ | ✴️ | | initialization of the component.should call the controller's `onInit` method and store the state of visibility.|

## Classes

### OdsFlagController
_common controller logic for flag component used by the different implementations._
_it contains all the glue between framework implementation and the third party service._

#### Methods
> **load**() => _unknown_

> **onDestroy**() => _unknown_

> **onInit**() => _unknown_

> **validateISO**() => _unknown_


### OdsFlagMock

## Type alias

### OdsFlag

interface description of all implementation of `ods-flag`.
each implementation must have defined events, methods, attributes
and one controller for the common behavior logic

> - `OdsComponentGenericMethods`
> - `OdsComponentGenericEvents`
### OdsFlagAttributes

> _Based on `OdsComponentAttributes`_
### OdsFlagEvents

> _Based on `OdsComponentEvents`_
### OdsFlagMethods

> _Based on `OdsComponentMethods`_
## Variables

### odsFlagDefaultAttributes
`OdsFlagAttributes`
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
| Name | Type | Default value | Description |
|----------|----------------------------------------------|---------------|---------------------------------------------|
| `iso` | **_COUNTRY_FLAG_ISO_CODE_** from `@ovhcloud/ods-core` | - | Country iso code for the corresponding flag |
| `iso` | **_COUNTRY_FLAG_ISO_CODE_** from `@ovhcloud/ods-common-core` | - | Country iso code for the corresponding flag |
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {Description} from '@storybook/addon-docs';
import Specs from './spec.md';
import SpecsFlagContents from './specifications-flag-contents.mdx';
import SpecsFlagTests from './specifications-flag-tests.mdx';

## Description
The flag component grow to the size of the parent's container

<Description>{Specs}</Description>

## Contents
<SpecsFlagContents />

## Tests
<SpecsFlagTests />
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Config } from '@jest/types';
import { OdsGetJestConfig } from '@ovhcloud/ods-testing';
import { OdsGetJestConfig } from '@ovhcloud/ods-common-testing';

const args = process.argv.slice(2);

Expand All @@ -15,9 +15,10 @@ const args = process.argv.slice(2);
* };
* ```
*/
// @ts-ignore until dependencies are fixed to one unique version of @jest/types
const config: Config.InitialOptions = {
...OdsGetJestConfig({
basePath: '<rootDir>/../../../..',
basePath: '<rootDir>/../../..',
args
}),
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@

// import { odsMockWindow } from '@ovhcloud/ods-testing/src/jest/ods-mock-window';

console.log('jest setup');
jest.mock('@ovhcloud/ods-core/src/configure/ods-get-window', () => ({
getOdsWindow: () => {
console.log('[odsMockWindow]', 'get mocked window YEAH2');
console.log('[odsMockWindow]', 'get mocked window');
return window;
}
}));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "@ovhcloud/ods-stencil-flag",
"name": "@ovhcloud/ods-component-flag",
"version": "15.0.1",
"private": true,
"description": "Flag component",
"description": "ODS Flag component",
"author": "OVH SAS",
"license": "Apache-2.0",
"main": "dist/index.cjs.js",
"module": "dist/index.js",
"es2015": "dist/esm/index.js",
"es2017": "dist/esm/index.js",
"types": "dist/types/components.d.ts",
"types": "dist/types/index.d.ts",
"collection": "dist/collection/collection-manifest.json",
"collection:main": "dist/collection/index.js",
"scripts": {
Expand All @@ -36,11 +36,14 @@
"test:e2e:ci:screenshot:update": "stencil test --config stencil.config.ts --e2e --ci --screenshot --update-screenshot --passWithNoTests"
},
"dependencies": {
"@ovhcloud/ods-stencil-component": "^15.0.1",
"@ovhcloud/ods-common-core": "^15.0.1",
"@ovhcloud/ods-common-stencil": "^15.0.1",
"@ovhcloud/ods-theming": "^15.0.1",
"flag-icons": "^6.6.6",
"workbox-build": "4.3.1"
},
"devDependencies": {
"@ovhcloud/ods-stencil-component-dev": "^15.0.1"
"@ovhcloud/ods-common-testing": "^15.0.1",
"@ovhcloud/ods-stencil-dev": "^15.0.1"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@ovhcloud/ods-stencil-flag-react",
"name": "@ovhcloud/ods-component-flag-react",
"version": "15.0.1",
"private": true,
"description": "React specific wrapper for ods",
Expand All @@ -20,18 +20,13 @@
"dist/"
],
"dependencies": {
"tslib": "*"
"@ovhcloud/ods-component-flag": "^15.0.1"
},
"peerDependencies": {
"react": ">=16.8.6",
"react-dom": ">=16.8.6"
},
"devDependencies": {
"@types/react": "17.0.37",
"@types/react-dom": "17.0.11",
"react": "16.14.0",
"react-dom": "16.14.0",
"rimraf": "^3.0.2",
"typescript": "4.7.4"
"@ovhcloud/ods-react-dev": "^15.0.1"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { OdsFlagAttribute } from '../interfaces/attributes';
import { ODS_COUNTRY_ISO_CODE } from '@ovhcloud/ods-common-core';

/**
* default attribute values of flag
*/
const DEFAULT_ATTRIBUTE: OdsFlagAttribute = Object.freeze({
iso: ODS_COUNTRY_ISO_CODE.FR,
lazy: false,
src: '',
assetPath: '',
});

export {
DEFAULT_ATTRIBUTE,
};
Loading

0 comments on commit 5e0ea78

Please sign in to comment.