Skip to content

Commit

Permalink
feat(phone-number): step 1 init component with simple input
Browse files Browse the repository at this point in the history
  • Loading branch information
aesteves60 authored and dpellier committed Sep 25, 2023
1 parent 871c2f3 commit c60e794
Show file tree
Hide file tree
Showing 49 changed files with 709 additions and 0 deletions.
33 changes: 33 additions & 0 deletions packages-new/components/phone-number/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
dist/
custom-elements/
custom-elements-bundle/
www/
loader/
docs-api
src/components.d.ts

*~
*.sw[mnpcod]
*.log
*.lock
*.tmp
*.tmp.*
log.txt
*.sublime-project
*.sublime-workspace

.stencil/
screenshot/
.idea/
.vscode/
.sass-cache/
.versions/
node_modules/
$RECYCLE.BIN/

.DS_Store
Thumbs.db
UserInterfaceState.xcuserstate
.env

src/**/readme.md
4 changes: 4 additions & 0 deletions packages-new/components/phone-number/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
!dist/
!loader/
!docs-api/
src/
Empty file.
5 changes: 5 additions & 0 deletions packages-new/components/phone-number/THIRD-PARTY-LICENCES
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This file was generated with the generate-license-file npm package!
https://www.npmjs.com/package/generate-license-file

This file was generated with the generate-license-file npm package!
https://www.npmjs.com/package/generate-license-file
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
| Name | default | Description |
|---------|---------|-------------|
| - | '' | |
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_none_
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_none_
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
| Name | Type | default | Description |
|------|------|---------|-------------|
| | | | |
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_none_
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import {Description} from '@storybook/addon-docs';
import Specs from './spec.md';
import SpecsPhoneNumberContents from './specifications-phone-number-contents.mdx';
import SpecsPhoneNumberTests from './specifications-phone-number-tests.mdx';

<Description>{Specs}</Description>

## Contents
<SpecsPhoneNumberContents />

## Tests
<SpecsPhoneNumberTests />
23 changes: 23 additions & 0 deletions packages-new/components/phone-number/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import type { Config } from '@jest/types';
import { OdsGetJestConfig } from '@ovhcloud/ods-common-testing';

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

/**
* synchronous config for jest.
*
* example with async config :
* ```typescript
* export default async (): Promise<Config.InitialOptions> => {
* return {
* verbose: true,
* };
* };
* ```
*/
// @ts-ignore until dependencies are fixed to one unique version of @jest/types
const config: Config.InitialOptions = OdsGetJestConfig({
basePath: '<rootDir>/../../..',
args
});
export default config;
46 changes: 46 additions & 0 deletions packages-new/components/phone-number/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"name": "@ovhcloud/ods-component-phone-number",
"version": "15.0.1",
"description": "ODS Phone number 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/index.d.ts",
"collection": "dist/collection/collection-manifest.json",
"collection:main": "dist/collection/index.js",
"scripts": {
"build:prod": "npm run build:stencil --if-present && npm run build:react --if-present && npm run build:vue --if-present",
"build": "echo \"use build:prod\"",
"build:stencil": "stencil build --docs --prod --config stencil.config.ts",
"build:react": "npm --prefix react run build",
"build:vue": "npm --prefix vue run build",
"watch": "stencil build --docs --watch --dev --config stencil.config.ts",
"start": "stencil build --docs --dev --watch --serve",
"ignore:rm": "git clean -Xdf",
"generate": "stencil generate",
"doc:api": "typedoc",
"generate:licence": "npx generate-license-file --input package.json --output THIRD-PARTY-LICENCES --overwrite",
"test": "yarn run test:spec && yarn run test:e2e",
"test:spec": "stencil test --spec --config stencil.config.ts --coverage",
"test:spec:ci": "stencil test --config stencil.config.ts --spec --ci --coverage",
"test:e2e": "stencil test --e2e --config stencil.config.ts",
"test:e2e:screenshot": "stencil test --e2e --screenshot --config stencil.config.ts --passWithNoTests",
"test:e2e:screenshot:update": "stencil test --e2e --screenshot --config stencil.config.ts --update-screenshot --passWithNoTests",
"test:e2e:ci": "stencil test --config stencil.config.ts --e2e --ci",
"test:e2e:ci:screenshot": "stencil test --config stencil.config.ts --e2e --ci --screenshot --passWithNoTests",
"test:e2e:ci:screenshot:update": "stencil test --config stencil.config.ts --e2e --ci --screenshot --update-screenshot --passWithNoTests"
},
"dependencies": {
"@ovhcloud/ods-common-core": "^15.0.1",
"@ovhcloud/ods-common-stencil": "^15.0.1",
"@ovhcloud/ods-common-theming": "^15.0.1",
"@ovhcloud/ods-component-input": "^15.0.1"
},
"devDependencies": {
"@ovhcloud/ods-common-testing": "^15.0.1",
"@ovhcloud/ods-stencil-dev": "^15.0.1"
}
}
2 changes: 2 additions & 0 deletions packages-new/components/phone-number/react/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist/
src/
2 changes: 2 additions & 0 deletions packages-new/components/phone-number/react/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
!dist/
src/
6 changes: 6 additions & 0 deletions packages-new/components/phone-number/react/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Change Log

All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

[Latest version](https://ovhcloud.design/latest/?path=/docs/design-system-changelog--page)
32 changes: 32 additions & 0 deletions packages-new/components/phone-number/react/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "@ovhcloud/ods-component-phone-number-react",
"version": "15.0.1",
"private": true,
"description": "React specific wrapper for ods",
"keywords": [],
"author": "OVH SAS",
"license": "Apache-2.0",
"scripts": {
"build": "npm run clean && npm run compile",
"clean": "rimraf dist",
"compile": "npm run compile:esm && npm run compile:cjs",
"compile:esm": "tsc -p tsconfig.json",
"compile:cjs": "tsc -p tsconfig.cjs.json"
},
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"types": "dist/types/index.d.ts",
"files": [
"dist/"
],
"dependencies": {
"@ovhcloud/ods-component-phone-number": "^15.0.1"
},
"peerDependencies": {
"react": ">=16.8.6",
"react-dom": ">=16.8.6"
},
"devDependencies": {
"@ovhcloud/ods-react-dev": "^15.0.1"
}
}
9 changes: 9 additions & 0 deletions packages-new/components/phone-number/react/tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "dist/cjs",
"module": "CommonJS",
"declaration": false,
"declarationDir": null
}
}
8 changes: 8 additions & 0 deletions packages-new/components/phone-number/react/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../../tsconfig.react.json",
"compilerOptions": {
"outDir": "dist/esm",
"declarationDir": "dist/types"
},
"include": ["src/**/*.ts", "src/**/*.tsx"]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type { OdsPhoneNumberAttribute } from '../interfaces/attributes';

const DEFAULT_ATTRIBUTE: OdsPhoneNumberAttribute = Object.freeze({
clearable: false,
disabled: false,
error: false,
value: '',
});

export {
DEFAULT_ATTRIBUTE,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
interface OdsPhoneNumberAttribute {
/** Ability to clear the phone number value */
clearable?: boolean;
disabled?: boolean;
/** Indicates if the phone number shows error or not */
error?: boolean;
/** Current value of the phone number */
value: string;
}

export {
OdsPhoneNumberAttribute,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import type { E2EElement, E2EPage } from '@stencil/core/testing';
import type { OdsPhoneNumberAttribute } from './interfaces/attributes';
import { newE2EPage } from '@stencil/core/testing';
import { odsComponentAttributes2StringAttributes, odsStringAttributes2Str } from '@ovhcloud/ods-common-testing';
import { DEFAULT_ATTRIBUTE } from './constants/default-attributes';

describe('e2e:osds-phone-number', () => {
const baseAttribute = { ariaLabel: '', forbiddenValues: [], value: '' };
let page: E2EPage;
let el: E2EElement;

async function setup({ attributes = {}, onPage }: { attributes?: Partial<OdsPhoneNumberAttribute>, onPage?: ({ page }: { page: E2EPage }) => void } = {}) {
const stringAttributes = odsComponentAttributes2StringAttributes<OdsPhoneNumberAttribute>({ ...baseAttribute, ...attributes }, DEFAULT_ATTRIBUTE);

page = await newE2EPage();
onPage && onPage({ page });

await page.setContent(`<osds-phone-number ${odsStringAttributes2Str(stringAttributes)}></osds-phone-number>`);
await page.evaluate(() => document.body.style.setProperty('margin', '0px'));

el = await page.find('osds-phone-number');
}

describe('attributes', () => {
[false, true].forEach((disabled) => {
[false, true].forEach((error) => {
[false, true].forEach((clearable) => {
['', 'value'].forEach((value) => {
it([disabled, error, clearable,,value].join(', '), async () => {
await setup({
attributes: {
disabled,
error,
clearable,
value,
},
});
await page.waitForChanges();

await page.evaluate(() => {
const element = document.querySelector('osds-phone-number') as HTMLElement;
return { width: element.clientWidth, height: element.clientHeight };
});
await page.setViewport({ width: 600, height:600 });
const results = await page.compareScreenshot('phone-number', { fullPage: false, omitBackground: true });
expect(results).toMatchScreenshot({ allowableMismatchedRatio: 0 })
});
});
});
});
});
})
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import type { OdsPhoneNumberAttribute } from './interfaces/attributes';
import type { E2EElement, E2EPage } from '@stencil/core/testing';
import { newE2EPage } from '@stencil/core/testing';
import { odsComponentAttributes2StringAttributes, odsStringAttributes2Str } from '@ovhcloud/ods-common-testing';
import { DEFAULT_ATTRIBUTE } from './constants/default-attributes';

describe('e2e:osds-phone-number', () => {
const baseAttribute = { value: '' };
let page: E2EPage;
let el: E2EElement;

async function setup({ attributes }: { attributes: Partial<OdsPhoneNumberAttribute> }) {
const stringAttributes = odsComponentAttributes2StringAttributes<OdsPhoneNumberAttribute>({ ...baseAttribute, ...attributes }, DEFAULT_ATTRIBUTE);

page = await newE2EPage();
await page.setContent(`<osds-phone-number ${odsStringAttributes2Str(stringAttributes)}></osds-phone-number>`);
await page.evaluate(() => document.body.style.setProperty('margin', '0px'));

el = await page.find('osds-phone-number');
}

it('should render', async () => {
await setup({ attributes: {} });
expect(el).not.toBeNull();
expect(el).toHaveClass('hydrated');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@import '~@ovhcloud/ods-common-theming/color/ods-theming-color';
@import '~@ovhcloud/ods-common-theming/ods-theme';

Loading

0 comments on commit c60e794

Please sign in to comment.
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy