-

   rss_rss_hh_new

 - e-mail

 

 -

 LiveInternet.ru:
: 17.03.2011
:
:
: 51

:


[ ] Angular 2+

, 19 2017 . 15:38 +
.

, , , , , . (theme) , ( ).
, Angular, , ButtonComponent ( button.component.css), . : dark light, ( , , , .. , css).

light , :

.my-button {
  padding: 10px;
  font-size: 14px;
  color: midnightblue;
  border: 1px solid mdnightblue;
  background: white;
  cursor: pointer;
}

my-button:disabled {
  pointer-events: none;
  cursor: default;
  color: grey;
  border: 1px solid grey;
}

dark :

.my-button {
  padding: 10px;
  font-size: 14px;
  color: lightblue;
  border: 1px solid lightblue;
  background: midnightblue;
  cursor: pointer;
}

.my-button:disabled {
  pointer-events: none;
  cursor: default;
  background: grey;
  color: lightgrey;
  border: 1px solid lightgrey;
}

. , , button-core.component.css. , button-light.component.css button-dark.component.css. , , ( ):

button-core.css:

.my-button {
  padding: 10px;
  font-size: 14px;
  cursor: pointer;
}

.my-button:disabled {
  pointer-events: none;
  cursor: default;
}

button-light.css:

.my-button {
  color: midnightblue;
  border: 1px solid mdnightblue;
  background: white;
}

my-button:disabled {
  color: grey;
  border: 1px solid grey;
}

button-dark.css:

.my-button {
  color: lightblue;
  border: 1px solid lightblue;
  background: midnightblue;
}

.my-button:disabled {
  background: grey;
  color: lightgrey;
  border: 1px solid lightgrey;
}

, button.component.css :

@import 'button-core.css'
@import 'button-light.css'
@import 'button-dark.css'

, , , .

, , .

:host-context(). ? css , , . , . . : parent-component child-component. , Angular, , child-component , , , parent-component ( hover). , , ViewEncapsulation: none, child-component Input , :

:host-context(.parent-component:hover) .child-component {
  background: lightcoral;
}

. - - (:host-context(.some-style)), . light- :

button-light.css:

:host-context(.light-theme) .my-button {
  color: midnightblue;
  border: 1px solid mdnightblue;
  background: white;
}

:host-context(.light-theme) my-button:disabled {
  color: grey;
  border: 1px solid grey;
}

dark-theme .

? , light-theme dark-theme, , . , , , , div app-component ( , bootstrap ). theme

[ngClass]="{'light-theme': theme === 'light', 'dark-theme': theme === 'dark'}".

, .

css . , .. . sass . , .

, , - . , , , .
Original source: habrahabr.ru (comments, light).

https://habrahabr.ru/post/333716/

:  

: [1] []
 

:
: 

: ( )

:

  URL