Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add toast style docs #1463

Merged
merged 1 commit into from
Aug 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 107 additions & 0 deletions en/components/toast.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,113 @@ public show(toast) {

<div class="divider--half"></div>

### Styling

To get started with styling the toast, we need to import the index file, where all the theme functions and component mixins live:

```scss
@import '~igniteui-angular/lib/core/styles/themes/index';
```

Following the simplest approach, we create a new theme that extends the [`igx-toast-theme`]({environment:sassApiUrl}/index.html#function-igx-toast-theme) and accepts the `$background`, `$text-color` and the `$border-radius` parameters.

```scss
$dark-toast: igx-toast-theme(
$background: #292826,
$text-color: #FFCD0F,
$border-radius: 12px
);
```

The last step is to **include** the newly created theme.

```scss
@include igx-toast($dark-toast);
```

>[!NOTE]
>If the component is using an [`Emulated`](themes/component-themes.md#view-encapsulation) ViewEncapsulation, it is necessary to `penetrate` this encapsulation using `::ng-deep`:

```scss
:host {
::ng-deep {
@include igx-toast($dark-toast);
}
}
```

#### Defining a color palette

Instead of hardcoding the color values like we just did, we can achieve greater flexibility in terms of colors by using the [`igx-palette`]({environment:sassApiUrl}/index.html#function-igx-palette) and [`igx-color`]({environment:sassApiUrl}/index.html#function-igx-color) functions.

`igx-palette` generates a color palette based on the primary and secondary colors that are passed:

```scss
$yellow-color: #FFCD0F;
$black-color: #292826;

$dark-palette: igx-palette($primary: $black-color, $secondary: $yellow-color);
```

And then with [`igx-color`]({environment:sassApiUrl}/index.html#function-igx-color) we can easily retrieve color from the palette.

```scss
$dark-toast: igx-toast-theme(
$background: igx-color($dark-palette, "primary", 400),
$text-color: igx-color($dark-palette, "secondary", 400),
$border-radius: 12px
);
```

>[!NOTE]
>The `igx-color` and `igx-palette` are powerful functions for generating and retrieving colors. Please refer to [`Palettes`](themes/palette.md) topic for detailed guidance on how to use them.

#### Using Schemas

Going further with the theming engine, you can build a robust and flexible structure that benefits from [**schemas**](themes/schemas.md). A **schema** is a recipe of a theme.

Extend one of the two predefined schemas, that are provided for every component, in this case - [`dark-toast`]({environment:sassApiUrl}/index.html#variable-_dark-toast) schema:

```scss
// Extending the toast schema
$dark-toast-schema: extend($_dark-toast,
(
background: (
igx-color: ("primary", 400)
),
text-color: (
igx-color: ("secondary", 400)
),
border-radius: 12px
)
);
```

In order to apply our custom schemas we have to **extend** one of the globals ([`light`]({environment:sassApiUrl}/index.html#variable-light-schema) or [`dark`]({environment:sassApiUrl}/index.html#variable-dark-schema)), which is basically pointing out the components with a custom schema, and after that add it to the respective component themes:

```scss
// Extending the global dark-schema
$custom-dark-schema: extend($dark-schema,(
igx-toast: $dark-toast-schema
));

// Defining toast with the global dark schema
$dark-toast: igx-toast-theme(
$palette: $dark-palette,
$schema: $custom-dark-schema
);
```

Don't forget to include the themes in the same way as it was demonstrated above.

<div class="sample-container loading" style="height: 200px">
<iframe id="toast-style-iframe" frameborder="0" seamless="" width="100%" height="100%" data-src="{environment:demosBaseUrl}/notifications/toast-style" class="lazyload no-theming"></iframe>
</div>
<div>
<button data-localize="stackblitz" disabled class="stackblitz-btn" data-iframe-id="toast-style-iframe" data-demos-base-url="{environment:demosBaseUrl}">view on stackblitz</button>
</div>
<div class="divider--half"></div>

### API References
In this article we learned how to use and configure the [`IgxToastComponent`]({environment:angularApiUrl}/classes/igxtoastcomponent.html). For more details in regards its API, take a look at the links below:

Expand Down
107 changes: 107 additions & 0 deletions jp/components/toast.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,113 @@ public show(toast) {

<div class="divider--half"></div>

### Styling

To get started with styling the toast, we need to import the index file, where all the theme functions and component mixins live:

```scss
@import '~igniteui-angular/lib/core/styles/themes/index';
```

Following the simplest approach, we create a new theme that extends the [`igx-toast-theme`]({environment:sassApiUrl}/index.html#function-igx-toast-theme) and accepts the `$background`, `$text-color` and the `$border-radius` parameters.

```scss
$dark-toast: igx-toast-theme(
$background: #292826,
$text-color: #FFCD0F,
$border-radius: 12px
);
```

The last step is to **include** the newly created theme.

```scss
@include igx-toast($dark-toast);
```

>[!NOTE]
>If the component is using an [`Emulated`](themes/component-themes.md#view-encapsulation) ViewEncapsulation, it is necessary to `penetrate` this encapsulation using `::ng-deep`:

```scss
:host {
::ng-deep {
@include igx-toast($dark-toast);
}
}
```

#### Defining a color palette

Instead of hardcoding the color values like we just did, we can achieve greater flexibility in terms of colors by using the [`igx-palette`]({environment:sassApiUrl}/index.html#function-igx-palette) and [`igx-color`]({environment:sassApiUrl}/index.html#function-igx-color) functions.

`igx-palette` generates a color palette based on the primary and secondary colors that are passed:

```scss
$yellow-color: #FFCD0F;
$black-color: #292826;

$dark-palette: igx-palette($primary: $black-color, $secondary: $yellow-color);
```

And then with [`igx-color`]({environment:sassApiUrl}/index.html#function-igx-color) we can easily retrieve color from the palette.

```scss
$dark-toast: igx-toast-theme(
$background: igx-color($dark-palette, "primary", 400),
$text-color: igx-color($dark-palette, "secondary", 400),
$border-radius: 12px
);
```

>[!NOTE]
>The `igx-color` and `igx-palette` are powerful functions for generating and retrieving colors. Please refer to [`Palettes`](themes/palette.md) topic for detailed guidance on how to use them.

#### Using Schemas

Going further with the theming engine, you can build a robust and flexible structure that benefits from [**schemas**](themes/schemas.md). A **schema** is a recipe of a theme.

Extend one of the two predefined schemas, that are provided for every component, in this case - [`dark-toast`]({environment:sassApiUrl}/index.html#variable-_dark-toast) schema:

```scss
// Extending the toast schema
$dark-toast-schema: extend($_dark-toast,
(
background: (
igx-color: ("primary", 400)
),
text-color: (
igx-color: ("secondary", 400)
),
border-radius: 12px
)
);
```

In order to apply our custom schemas we have to **extend** one of the globals ([`light`]({environment:sassApiUrl}/index.html#variable-light-schema) or [`dark`]({environment:sassApiUrl}/index.html#variable-dark-schema)), which is basically pointing out the components with a custom schema, and after that add it to the respective component themes:

```scss
// Extending the global dark-schema
$custom-dark-schema: extend($dark-schema,(
igx-toast: $dark-toast-schema
));

// Defining toast with the global dark schema
$dark-toast: igx-toast-theme(
$palette: $dark-palette,
$schema: $custom-dark-schema
);
```

Don't forget to include the themes in the same way as it was demonstrated above.

<div class="sample-container loading" style="height: 200px">
<iframe id="toast-style-iframe" frameborder="0" seamless="" width="100%" height="100%" data-src="{environment:demosBaseUrl}/notifications/toast-style" class="lazyload no-theming"></iframe>
</div>
<div>
<button data-localize="stackblitz" disabled class="stackblitz-btn" data-iframe-id="toast-style-iframe" data-demos-base-url="{environment:demosBaseUrl}">view on stackblitz</button>
</div>
<div class="divider--half"></div>

### API リファレンス

このトピックでは、[`IgxToastComponent`]({environment:angularApiUrl}/classes/igxtoastcomponent.html) を使用と構成方法を説明しました。API の詳細については以下のリンク先を参照してください。
Expand Down