-
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 chip
- Loading branch information
Showing
87 changed files
with
575 additions
and
607 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
80 changes: 80 additions & 0 deletions
80
packages-new/components/chip/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,80 @@ | ||
* [**Interfaces**](#interfaces) | ||
* [**Types**](#types) | ||
* [**Classes**](#classes) | ||
* [**Type alias**](#type-alias) | ||
* [**Variables**](#variables) | ||
|
||
## Interfaces | ||
|
||
### OdsChipAttributes | ||
|name | Type | Required | Default | Description| | ||
|---|---|:---:|---|---| | ||
|**`color`** | `OdsThemeColorIntent` | | | Chip color theme| | ||
|**`contrasted`** | _boolean_ | | | Chip is in contrasterd mode or not| | ||
|**`disabled`** | _boolean_ | | | Chip is disabled or not| | ||
|**`flex`** | _boolean_ | | | Chip as flex| | ||
|**`removable`** | _boolean_ | | | If the chip can be removed or not| | ||
|**`selectable`** | _boolean_ | | | If the chip can be selected or not| | ||
|**`size`** | `OdsChipSize` | | | Chip size| | ||
|**`variant`** | `OdsChipVariant` | | | Chip variant| | ||
|
||
### OdsChipBehavior | ||
|name | Type | Required | Default | Description| | ||
|---|---|:---:|---|---| | ||
|**`beforeRender`** | _void_ | ✴️ | | before render component functionshould be called before component render.it have to check the validity of attributes.| | ||
|
||
## Types | ||
|
||
### OdsChipSize | ||
| | | ||
|:---:| | ||
| `md` | | ||
| `sm` | | ||
|
||
### OdsChipVariant | ||
| | | ||
|:---:| | ||
| `flat` | | ||
| `stroked` | | ||
|
||
## Classes | ||
|
||
### OdsChipController | ||
_common controller logic for chip component used by the different implementations._ | ||
_it contains all the glue between framework implementation and the third party service._ | ||
|
||
#### Methods | ||
> **validateAttributes**() => _unknown_ | ||
|
||
|
||
### OdsChipMock | ||
|
||
## Type alias | ||
|
||
### OdsChip | ||
|
||
interface description of all implementation of `ods-chip`. | ||
each implementation must have defined events, methods, attributes | ||
and one controller for the common behavior logic | ||
|
||
> - `OdsComponentGenericMethods` | ||
> - `OdsComponentGenericEvents` | ||
### OdsChipAttributes | ||
|
||
> _Based on `OdsComponentAttributes`_ | ||
### OdsChipEvents | ||
|
||
> _Based on `OdsComponentEvents`_ | ||
### OdsChipMethods | ||
|
||
> _Based on `OdsComponentMethods`_ | ||
## Variables | ||
|
||
### odsChipDefaultAttributes | ||
`OdsChipAttributes` |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...s/components/chip/specifications-chip.mdx → ...on/specifications/specifications-chip.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
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.
11 changes: 11 additions & 0 deletions
11
packages-new/components/chip/src/components/osds-chip/constants/chip-size.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_CHIP_SIZE { | ||
sm = 'sm', | ||
md = 'md', | ||
} | ||
|
||
const ODS_CHIP_SIZES = Object.freeze(Object.values(ODS_CHIP_SIZE)); | ||
|
||
export { | ||
ODS_CHIP_SIZE, | ||
ODS_CHIP_SIZES, | ||
}; |
11 changes: 11 additions & 0 deletions
11
packages-new/components/chip/src/components/osds-chip/constants/chip-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_CHIP_VARIANT { | ||
flat = 'flat', | ||
stroked = 'stroked', | ||
} | ||
|
||
const ODS_CHIP_VARIANTS = Object.freeze(Object.values(ODS_CHIP_VARIANT)); | ||
|
||
export { | ||
ODS_CHIP_VARIANT, | ||
ODS_CHIP_VARIANTS, | ||
}; |
19 changes: 19 additions & 0 deletions
19
packages-new/components/chip/src/components/osds-chip/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,19 @@ | ||
import type { OdsChipAttribute } from '../interfaces/attributes'; | ||
import { OdsThemeColorIntent } from '@ovhcloud/ods-theming'; | ||
import { ODS_CHIP_SIZE } from './chip-size'; | ||
import { ODS_CHIP_VARIANT } from './chip-variant'; | ||
|
||
const DEFAULT_ATTRIBUTE: OdsChipAttribute = Object.freeze({ | ||
color: OdsThemeColorIntent.default, | ||
contrasted: false, | ||
disabled: false, | ||
inline: false, | ||
removable: false, | ||
selectable: false, | ||
size: ODS_CHIP_SIZE.md, | ||
variant: ODS_CHIP_VARIANT.flat, | ||
}); | ||
|
||
export { | ||
DEFAULT_ATTRIBUTE, | ||
}; |
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
44 changes: 44 additions & 0 deletions
44
packages-new/components/chip/src/components/osds-chip/core/controller.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,44 @@ | ||
import type { OsdsChip } from '../osds-chip'; | ||
import { OdsLogger, OdsWarnComponentAttribute } from '@ovhcloud/ods-common-core'; | ||
import { OdsThemeColorIntent } from '@ovhcloud/ods-theming'; | ||
import { ODS_CHIP_SIZE } from '../constants/chip-size'; | ||
import { ODS_CHIP_VARIANT } from '../constants/chip-variant'; | ||
|
||
class OdsChipController { | ||
private component: OsdsChip; | ||
private readonly logger = new OdsLogger('OdsChipController'); | ||
|
||
constructor(component: OsdsChip) { | ||
this.component = component; | ||
} | ||
|
||
/** | ||
* validating that the color, the size and the variant have correct values | ||
* and warn the user if not | ||
*/ | ||
validateAttributes(): void { | ||
const logger = this.logger; | ||
OdsWarnComponentAttribute<OdsThemeColorIntent, OsdsChip>({ | ||
logger, | ||
attributeValues: OdsThemeColorIntent as Record<string, unknown>, | ||
attributeName: 'color', | ||
attribute: this.component.color | ||
}); | ||
OdsWarnComponentAttribute<ODS_CHIP_SIZE, OsdsChip>({ | ||
logger, | ||
attributeValues: ODS_CHIP_SIZE as Record<string, unknown>, | ||
attributeName: 'size', | ||
attribute: this.component.size | ||
}); | ||
OdsWarnComponentAttribute<ODS_CHIP_VARIANT, OsdsChip>({ | ||
logger, | ||
attributeValues: ODS_CHIP_VARIANT as Record<string, unknown>, | ||
attributeName: 'variant', | ||
attribute: this.component.variant | ||
}); | ||
} | ||
} | ||
|
||
export { | ||
OdsChipController, | ||
}; |
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
Oops, something went wrong.