-
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(compiler): add support for plain TypeScript classes without deco…
…rators (#215) - Deprecate `extends Component<T?>` and `@property` semantics required for component authoring. Dangling references remain in `@diez/engine` for legacy projects created before the next release, but they are no longer functional. - Allow design token components to be built with plain TypeScript classes, punching `public`-scoped instance properties through to transpiled SDKs and leaving everything else out. We are now equipped to easily add support for typed hashmaps, but that should come in a subsequent PR. - Provide a new, more strongly typed generic factory for prefab base classes. It would have been lovely to do this with just an abstract base class and not a factory, but sadly, TypeScript has a few limitations with regard to typing classes whose constructors mutate the class type to conform to a generic interface whose type is not known statically at compile time. The new syntax is: ``` import {prefab} from '@diez/engine'; interface FooData { bar: string; } class Foo extends prefab<FooData>() { defaults = { bar: 'bar', }; } ``` With the power of abstract classes, generics, and ES6 proxies, `new Foo()` and `new Foo({bar: string})` satisfy `Prefab<FooData> & FooData` automatically and without the need to carefully register data properties matching the types of the state shape. - Migrate example projects and documentation to use/refer to this new syntax.
- Loading branch information
Showing
68 changed files
with
872 additions
and
1,837 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,16 @@ | ||
import {Component, property} from '@diez/engine'; | ||
import {LoadingDesign, NavigationTitleDesign, palette, ReportDesign, typographs} from './designs'; | ||
|
||
class Designs extends Component { | ||
@property report = new ReportDesign(); | ||
@property loading = new LoadingDesign(); | ||
@property navigationTitle = new NavigationTitleDesign(); | ||
class Designs { | ||
report = new ReportDesign(); | ||
loading = new LoadingDesign(); | ||
navigationTitle = new NavigationTitleDesign(); | ||
} | ||
|
||
/** | ||
* The design system for Poodle Surf. | ||
*/ | ||
export class DesignSystem extends Component { | ||
@property palette = palette; | ||
@property typographs = typographs; | ||
@property designs = new Designs(); | ||
export class DesignSystem { | ||
palette = palette; | ||
typographs = typographs; | ||
designs = new Designs(); | ||
} |
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,9 +1,8 @@ | ||
import {Component, property} from '@diez/engine'; | ||
import {ReportModelMock} from './mocks'; | ||
|
||
/** | ||
* The model mocks for Poodle Surf. | ||
*/ | ||
export class ModelMocks extends Component { | ||
@property report = new ReportModelMock(); | ||
export class ModelMocks { | ||
report = new ReportModelMock(); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,13 @@ | ||
import {PoodleSurfSlices} from './PoodleSurf.sketch'; | ||
import {Component, property} from '@diez/engine'; | ||
import {LayoutValues, palette, typographs} from './constants'; | ||
|
||
/** | ||
* The navigation title design. | ||
*/ | ||
export class NavigationTitleDesign extends Component { | ||
@property barTintColor = palette.background; | ||
@property icon = PoodleSurfSlices.Icon; | ||
@property title = 'P o o d l e S u r f'; | ||
@property typograph = typographs.headerTitle; | ||
@property iconToTitleSpacing = LayoutValues.DefaultSpacing; | ||
export class NavigationTitleDesign { | ||
barTintColor = palette.background; | ||
icon = PoodleSurfSlices.Icon; | ||
title = 'P o o d l e S u r f'; | ||
typograph = typographs.headerTitle; | ||
iconToTitleSpacing = LayoutValues.DefaultSpacing; | ||
} |
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.