From a99d8d6b09cd551db8ed8c65ee026125002cdf70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=87etin?= <69278826+cetincakiroglu@users.noreply.github.com> Date: Tue, 26 Dec 2023 18:38:53 +0300 Subject: [PATCH] Refactor --- .../doc/guides/csslayer/specificitydoc.ts | 59 +++++++++++-------- .../showcase/layout/doc/app.code.component.ts | 3 +- .../layout/doc/app.docsection.component.ts | 6 +- .../guides/csslayer/csslayerdemo.component.ts | 11 ++-- 4 files changed, 44 insertions(+), 35 deletions(-) diff --git a/src/app/showcase/doc/guides/csslayer/specificitydoc.ts b/src/app/showcase/doc/guides/csslayer/specificitydoc.ts index 3491bb16dda..d420b2c9ba5 100644 --- a/src/app/showcase/doc/guides/csslayer/specificitydoc.ts +++ b/src/app/showcase/doc/guides/csslayer/specificitydoc.ts @@ -1,16 +1,15 @@ -import { Component } from '@angular/core'; +import { Component, ViewEncapsulation } from '@angular/core'; import { Code } from 'src/app/showcase/domain/code'; @Component({ selector: 'specificity-doc', - template: `

A CSS layer is utilized in styled mode only, in unstyled mode the built-in CSS classes are not included and as a result no layer is defined. This documentation only applies to styled mode.

The @layer is a standard CSS feature to define cascade layers for a customizable order of precedence. If you need to become more familiar with layers, visit the documentation at - MDN to begin with. In styled mode, PrimeNG wraps the built-in style classes under the primeNG cascade layer to make the library styles easy to override. CSS - in your app without a layer has the highest CSS specificity, so you'll be able to override styles regardless of the location or how strong a class is written. + MDN to begin with. PrimeNG wraps the built-in style classes under the primeNG cascade layer to make the library styles easy to override. CSS in your app + without a layer has the highest CSS specificity, so you'll be able to override styles regardless of the location or how strong a class is written.

For example, let's assume you need to remove the rounded borders of the InputSwitch component defined by the theme in use. In order to achieve this, .p-inputswitch .p-inputswitch-slider selector needs to be overriden. Without @@ -21,38 +20,48 @@ import { Code } from 'src/app/showcase/domain/code'; - -

Layers also make it possible to use CSS Modules, view the CSS Modules guide for examples.

+
`, + encapsulation: ViewEncapsulation.None, styles: ` - :host ::ng-deep { - .my-inputswitch .p-inputswitch-slider { - border-radius: 0; - } - .my-inputswitch .p-inputswitch-slider:before { - border-radius: 0; - } - } - ` + .my-inputswitch .p-inputswitch-slider { + border-radius: 0; + } + .my-inputswitch .p-inputswitch-slider:before { + border-radius: 0; + }` }) export class SpecificityDoc { checked: boolean = false; - code: Code = { - basic: ` - - - ` +@Component({ + template: \` +
+ +
\`, + encapsulation: ViewEncapsulation.None, + styles: \` + .my-inputswitch .p-inputswitch-slider { + border-radius: 0; + } + .my-inputswitch .p-inputswitch-slider:before { + border-radius: 0; + } + \` +}) +export class ExampleComponent { + checked: boolean = false; +}` }; } diff --git a/src/app/showcase/layout/doc/app.code.component.ts b/src/app/showcase/layout/doc/app.code.component.ts index 039094b3cb2..ea97aa4c2f3 100644 --- a/src/app/showcase/layout/doc/app.code.component.ts +++ b/src/app/showcase/layout/doc/app.code.component.ts @@ -13,6 +13,7 @@ import { useCodeSandbox, useStackBlitz } from './codeeditor'; +