Skip to content

Commit

Permalink
fix(all): strong typing for color
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat committed May 14, 2018
1 parent 87fe5ce commit 618f708
Show file tree
Hide file tree
Showing 48 changed files with 186 additions and 157 deletions.
131 changes: 67 additions & 64 deletions core/src/components.d.ts

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions core/src/components/action-sheet/action-sheet.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Element, Event, EventEmitter, Listen, Method, Prop } from '@stencil/core';
import { ActionSheetButton, Animation, AnimationBuilder, Config, CssClassMap, Mode } from '../../interface';
import { ActionSheetButton, Animation, AnimationBuilder, Color, Config, CssClassMap, Mode } from '../../interface';
import { BACKDROP, OverlayEventDetail, OverlayInterface, dismiss, eventMethod, isCancel, present } from '../../utils/overlays';
import { createThemedClasses, getClassMap } from '../../utils/theme';
import { iosEnterAnimation } from './animations/ios.enter';
Expand All @@ -21,7 +21,7 @@ import { mdLeaveAnimation } from './animations/md.leave';
export class ActionSheet implements OverlayInterface {

mode!: Mode;
color!: string;
color?: Color;

presented = false;
animation?: Animation;
Expand Down
4 changes: 2 additions & 2 deletions core/src/components/alert/alert.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Element, Event, EventEmitter, Listen, Method, Prop, Watch } from '@stencil/core';
import { AlertButton, AlertInput, Animation, AnimationBuilder, Config, CssClassMap, Mode } from '../../interface';
import { AlertButton, AlertInput, Animation, AnimationBuilder, Color, Config, CssClassMap, Mode } from '../../interface';
import { BACKDROP, OverlayEventDetail, OverlayInterface, dismiss, eventMethod, isCancel, present } from '../../utils/overlays';
import { createThemedClasses, getClassMap } from '../../utils/theme';

Expand Down Expand Up @@ -27,7 +27,7 @@ export class Alert implements OverlayInterface {
presented = false;
animation?: Animation;

color!: string;
color!: Color;
@Prop() mode!: Mode;

@Element() el!: HTMLStencilElement;
Expand Down
4 changes: 2 additions & 2 deletions core/src/components/back-button/back-button.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Element, Prop } from '@stencil/core';
import { Config, Mode } from '../../interface';
import { Color, Config, Mode } from '../../interface';
import { createThemedClasses, getElementClassMap, openURL } from '../../utils/theme';

@Component({
Expand All @@ -24,7 +24,7 @@ export class BackButton {
* Default options are: `"primary"`, `"secondary"`, `"tertiary"`, `"success"`, `"warning"`, `"danger"`, `"light"`, `"medium"`, and `"dark"`.
* For more information, see [Theming your App](/docs/theming/theming-your-app).
*/
@Prop() color!: string;
@Prop() color?: Color;

/**
* The mode determines which platform styles to use.
Expand Down
4 changes: 2 additions & 2 deletions core/src/components/badge/badge.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Prop } from '@stencil/core';
import { Mode } from '../../interface';
import { Color, Mode } from '../../interface';


@Component({
Expand All @@ -19,7 +19,7 @@ export class Badge {
* Default options are: `"primary"`, `"secondary"`, `"tertiary"`, `"success"`, `"warning"`, `"danger"`, `"light"`, `"medium"`, and `"dark"`.
* For more information, see [Theming your App](/docs/theming/theming-your-app).
*/
@Prop() color!: string;
@Prop() color?: Color;

/**
* The mode determines which platform styles to use.
Expand Down
6 changes: 3 additions & 3 deletions core/src/components/button/button.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Element, Event, EventEmitter, Prop, State } from '@stencil/core';
import { CssClassMap, Mode, RouterDirection } from '../../interface';
import { Color, CssClassMap, Mode, RouterDirection } from '../../interface';
import { getButtonClassMap, getElementClassMap, openURL } from '../../utils/theme';


Expand All @@ -22,7 +22,7 @@ export class Button {
* Default options are: `"primary"`, `"secondary"`, `"tertiary"`, `"success"`, `"warning"`, `"danger"`, `"light"`, `"medium"`, and `"dark"`.
* For more information, see [Theming your App](/docs/theming/theming-your-app).
*/
@Prop() color!: string;
@Prop() color?: Color;

/**
* The mode determines which platform styles to use.
Expand Down Expand Up @@ -176,7 +176,7 @@ function getButtonTypeClassMap(buttonType: string, type: string|undefined, mode:
};
}

function getColorClassMap(buttonType: string, color: string, fill: string, mode: Mode): CssClassMap {
function getColorClassMap(buttonType: string, color: string | undefined, fill: string, mode: Mode): CssClassMap {
let className = buttonType;

if (buttonType !== 'bar-button' && fill === 'solid') {
Expand Down
4 changes: 2 additions & 2 deletions core/src/components/card-content/card-content.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Prop } from '@stencil/core';
import { Mode } from '../../interface';
import { Color, Mode } from '../../interface';

@Component({
tag: 'ion-card-content',
Expand All @@ -16,7 +16,7 @@ export class CardContent {
* The color to use for the text.
* Default options are: `"primary"`, `"secondary"`, `"tertiary"`, `"success"`, `"warning"`, `"danger"`, `"light"`, `"medium"`, and `"dark"`.
*/
@Prop() color!: string;
@Prop() color?: Color;

/**
* The mode determines which platform styles to use.
Expand Down
4 changes: 2 additions & 2 deletions core/src/components/card-header/card-header.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, Prop } from '@stencil/core';

import { Mode } from '../../interface';
import { Color, Mode } from '../../interface';
import { createThemedClasses } from '../../utils/theme';

@Component({
Expand All @@ -18,7 +18,7 @@ export class CardHeader {
* The color to use for the background.
* Default options are: `"primary"`, `"secondary"`, `"tertiary"`, `"success"`, `"warning"`, `"danger"`, `"light"`, `"medium"`, and `"dark"`.
*/
@Prop() color!: string;
@Prop() color?: Color;

/**
* The mode determines which platform styles to use.
Expand Down
4 changes: 2 additions & 2 deletions core/src/components/card-subtitle/card-subtitle.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Prop} from '@stencil/core';
import { Mode } from '../../interface';
import { Color, Mode } from '../../interface';


@Component({
Expand All @@ -17,7 +17,7 @@ export class CardSubtitle {
* The color to use for the text color.
* Default options are: `"primary"`, `"secondary"`, `"tertiary"`, `"success"`, `"warning"`, `"danger"`, `"light"`, `"medium"`, and `"dark"`.
*/
@Prop() color!: string;
@Prop() color?: Color;

/**
* The mode determines which platform styles to use.
Expand Down
4 changes: 2 additions & 2 deletions core/src/components/card-title/card-title.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Prop} from '@stencil/core';
import { Mode } from '../../interface';
import { Color, Mode } from '../../interface';


@Component({
Expand All @@ -18,7 +18,7 @@ export class CardTitle {
* The color to use for the text color.
* Default options are: `"primary"`, `"secondary"`, `"tertiary"`, `"success"`, `"warning"`, `"danger"`, `"light"`, `"medium"`, and `"dark"`.
*/
@Prop() color!: string;
@Prop() color?: Color;

/**
* The mode determines which platform styles to use.
Expand Down
4 changes: 2 additions & 2 deletions core/src/components/card/card.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Prop } from '@stencil/core';
import { Mode } from '../../interface';
import { Color, Mode } from '../../interface';

@Component({
tag: 'ion-card',
Expand All @@ -17,7 +17,7 @@ export class Card {
* The color to use for the background.
* Default options are: `"primary"`, `"secondary"`, `"tertiary"`, `"success"`, `"warning"`, `"danger"`, `"light"`, `"medium"`, and `"dark"`.
*/
@Prop() color!: string;
@Prop() color?: Color;

/**
* The mode determines which platform styles to use.
Expand Down
4 changes: 2 additions & 2 deletions core/src/components/checkbox/checkbox.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Element, Event, EventEmitter, Prop, State, Watch } from '@stencil/core';
import { CheckboxInput, CheckedInputChangeEvent, CssClassMap, Mode, StyleEvent } from '../../interface';
import { CheckboxInput, CheckedInputChangeEvent, Color, CssClassMap, Mode, StyleEvent } from '../../interface';
import { deferEvent } from '../../utils/helpers';


Expand All @@ -26,7 +26,7 @@ export class Checkbox implements CheckboxInput {
* The color to use.
* Default options are: `"primary"`, `"secondary"`, `"tertiary"`, `"success"`, `"warning"`, `"danger"`, `"light"`, `"medium"`, and `"dark"`.
*/
@Prop() color!: string;
@Prop() color?: Color;

/**
* The mode determines which platform styles to use.
Expand Down
6 changes: 3 additions & 3 deletions core/src/components/chip-button/chip-button.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Element, Prop } from '@stencil/core';
import { CssClassMap, Mode } from '../../interface';
import { Color, CssClassMap, Mode } from '../../interface';
import { getButtonClassMap, getElementClassMap } from '../../utils/theme';

@Component({
Expand All @@ -16,7 +16,7 @@ export class ChipButton {
* The color to use.
* Default options are: `"primary"`, `"secondary"`, `"tertiary"`, `"success"`, `"warning"`, `"danger"`, `"light"`, `"medium"`, and `"dark"`.
*/
@Prop() color!: string;
@Prop() color?: Color;

/**
* The mode determines which platform styles to use.
Expand Down Expand Up @@ -77,7 +77,7 @@ export class ChipButton {
/**
* Get the classes for the color
*/
function getColorClassMap(color: string, buttonType: string, style: string, mode: Mode): CssClassMap {
function getColorClassMap(color: string | undefined, buttonType: string, style: string, mode: Mode): CssClassMap {
const className = (style === 'default') ? `${buttonType}` : `${buttonType}-${style}`;

const map: CssClassMap = {
Expand Down
4 changes: 2 additions & 2 deletions core/src/components/chip/chip.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Prop } from '@stencil/core';
import { Mode } from '../../interface';
import { Color, Mode } from '../../interface';


@Component({
Expand All @@ -17,7 +17,7 @@ export class Chip {
* The color to use.
* Default options are: `"primary"`, `"secondary"`, `"tertiary"`, `"success"`, `"warning"`, `"danger"`, `"light"`, `"medium"`, and `"dark"`.
*/
@Prop() color!: string;
@Prop() color?: Color;

/**
* The mode determines which platform styles to use.
Expand Down
4 changes: 2 additions & 2 deletions core/src/components/content/content.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Element, Listen, Method, Prop } from '@stencil/core';
import { Config, Mode, QueueController } from '../../interface';
import { Color, Config, Mode, QueueController } from '../../interface';


@Component({
Expand All @@ -14,7 +14,7 @@ export class Content {
private scrollEl?: HTMLIonScrollElement;

mode!: Mode;
color!: string;
color?: Color;

@Element() el!: HTMLElement;

Expand Down
4 changes: 2 additions & 2 deletions core/src/components/fab-button/fab-button.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Element, Prop } from '@stencil/core';
import { CssClassMap, Mode } from '../../interface';
import { Color, CssClassMap, Mode } from '../../interface';
import { createThemedClasses, getElementClassMap } from '../../utils/theme';


Expand All @@ -21,7 +21,7 @@ export class FabButton {
* Default options are: `"primary"`, `"secondary"`, `"tertiary"`, `"success"`, `"warning"`, `"danger"`, `"light"`, `"medium"`, and `"dark"`.
* For more information, see [Theming your App](/docs/theming/theming-your-app).
*/
@Prop() color!: string;
@Prop() color?: Color;

/**
* The mode determines which platform styles to use.
Expand Down
4 changes: 2 additions & 2 deletions core/src/components/footer/footer.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, Prop } from '@stencil/core';

import { Mode } from '../../interface';
import { Color, Mode } from '../../interface';
import { createThemedClasses } from '../../utils/theme';

@Component({
Expand All @@ -15,7 +15,7 @@ import { createThemedClasses } from '../../utils/theme';
})
export class Footer {
mode!: Mode;
color!: string;
color?: Color;

/**
* If true, the footer will be translucent.
Expand Down
4 changes: 2 additions & 2 deletions core/src/components/header/header.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Component, Prop } from '@stencil/core';

import { Mode } from '../../interface';
import { Color, Mode } from '../../interface';
import { createThemedClasses } from '../../utils/theme';

@Component({
Expand All @@ -15,7 +15,7 @@ import { createThemedClasses } from '../../utils/theme';
})
export class Header {
mode!: Mode;
color!: string;
color?: Color;

/**
* If true, the header will be translucent.
Expand Down
4 changes: 2 additions & 2 deletions core/src/components/input/input.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Element, Event, EventEmitter, Prop, Watch } from '@stencil/core';
import { InputChangeEvent, Mode, StyleEvent } from '../../interface';
import { Color, InputChangeEvent, Mode, StyleEvent } from '../../interface';
import { debounceEvent, deferEvent } from '../../utils/helpers';
import { createThemedClasses } from '../../utils/theme';
import { InputComponent } from './input-base';
Expand All @@ -21,7 +21,7 @@ export class Input implements InputComponent {
didBlurAfterEdit = false;

mode!: Mode;
color!: string;
color?: Color;

@Element() el!: HTMLElement;

Expand Down
4 changes: 2 additions & 2 deletions core/src/components/item-divider/item-divider.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Element, Prop } from '@stencil/core';
import { Mode } from '../../interface';
import { Color, Mode } from '../../interface';


@Component({
Expand All @@ -20,7 +20,7 @@ export class ItemDivider {
* Default options are: `"primary"`, `"secondary"`, `"tertiary"`, `"success"`, `"warning"`, `"danger"`, `"light"`, `"medium"`, and `"dark"`.
* For more information, see [Theming your App](/docs/theming/theming-your-app).
*/
@Prop() color!: string;
@Prop() color?: Color;

/**
* The mode determines which platform styles to use.
Expand Down
4 changes: 2 additions & 2 deletions core/src/components/item-option/item-option.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Prop } from '@stencil/core';
import { Mode } from '../../interface';
import { Color, Mode } from '../../interface';


@Component({
Expand All @@ -18,7 +18,7 @@ export class ItemOption {
* Default options are: `"primary"`, `"secondary"`, `"tertiary"`, `"success"`, `"warning"`, `"danger"`, `"light"`, `"medium"`, and `"dark"`.
* For more information, see [Theming your App](/docs/theming/theming-your-app).
*/
@Prop() color!: string;
@Prop() color?: Color;

/**
* The mode determines which platform styles to use.
Expand Down
4 changes: 2 additions & 2 deletions core/src/components/item/item.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Element, Listen, Prop } from '@stencil/core';
import { CssClassMap, Mode, RouterDirection } from '../../interface';
import { Color, CssClassMap, Mode, RouterDirection } from '../../interface';
import { createThemedClasses, getElementClassMap, openURL } from '../../utils/theme';


Expand All @@ -23,7 +23,7 @@ export class Item {
* Default options are: `"primary"`, `"secondary"`, `"tertiary"`, `"success"`, `"warning"`, `"danger"`, `"light"`, `"medium"`, and `"dark"`.
* For more information, see [Theming your App](/docs/theming/theming-your-app).
*/
@Prop() color!: string;
@Prop() color?: Color;

/**
* The mode determines which platform styles to use.
Expand Down
4 changes: 2 additions & 2 deletions core/src/components/label/label.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Element, Event, EventEmitter, Method, Prop, Watch } from '@stencil/core';
import { Mode, StyleEvent } from '../../interface';
import { Color, Mode, StyleEvent } from '../../interface';


@Component({
Expand All @@ -21,7 +21,7 @@ export class Label {
* Default options are: `"primary"`, `"secondary"`, `"tertiary"`, `"success"`, `"warning"`, `"danger"`, `"light"`, `"medium"`, and `"dark"`.
* For more information, see [Theming your App](/docs/theming/theming-your-app).
*/
@Prop() color!: string;
@Prop() color?: Color;

/**
* The mode determines which platform styles to use.
Expand Down
4 changes: 2 additions & 2 deletions core/src/components/list-header/list-header.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, Prop } from '@stencil/core';
import { Mode } from '../../interface';
import { Color, Mode } from '../../interface';


@Component({
Expand All @@ -19,7 +19,7 @@ export class ListHeader {
* Default options are: `"primary"`, `"secondary"`, `"tertiary"`, `"success"`, `"warning"`, `"danger"`, `"light"`, `"medium"`, and `"dark"`.
* For more information, see [Theming your App](/docs/theming/theming-your-app).
*/
@Prop() color!: string;
@Prop() color?: Color;

/**
* The mode determines which platform styles to use.
Expand Down
Loading

0 comments on commit 618f708

Please sign in to comment.