🚀 DAY 3 OF LAUNCH WEEK: Introducing Webhook Events for Pull Request Scans.Learn more →
Socket
Book a DemoInstallSign in
Socket

@material/feature-targeting

Package Overview
Dependencies
Maintainers
15
Versions
1649
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@material/feature-targeting

Material Components for the web Feature Targeting Scss helpers

latest
Source
npmnpm
Version
14.0.0
Version published
Weekly downloads
562K
-18.32%
Maintainers
15
Weekly downloads
 
Created
Source

Feature Targeting

MDC Feature Targeting provides infrastructure to allow CSS styles to be included or excluded categorically.

Most of the time, you shouldn't need to depend on mdc-feature-targeting directly. However, understanding it can be useful if you're interested in having more control over when certain types of MDC styles are emitted.

Installation

npm install @material/feature-targeting

Basic Usage

Styles

Authoring component styles:

@use "@material/feature-targeting";

@mixin my-component-core-styles($query: feature-targeting.all()) {
  $feat-structure: feature-targeting.create-target($query, structure);

  @include feature-targeting.targets($feat-structure) {
    // ...
  }
}

Consuming component styles:

@use "@material/feature-targeting";
@use "my-component-mixins";

// To include all styles (using the default of mdc-feature-all() defined above):
@include my-component-core-styles;

// Or, to include a specific subset of styles:
@include my-component-core-styles(structure);
@include my-component-core-styles(feature-targeting.any(color, typography));
// The above two @includes and the following @include would produce equivalent results:
@include my-component-core-styles(feature-targeting.without(animation));

Sass Mixins and Functions

MixinDescription
targets($feature-targets...)Conditionalizes content to only be emitted if the given feature target(s) is/are queried.
FunctionDescription
create-target($feature-query, $targeted-feature)Returns a variable to be passed to targets in order to filter emitted styles.
all($feature-queries...)Returns a query object which will result in emitting targets blocks that match all of the specified features. Passing no arguments results in all blocks being emitted, which is the most common use case.
any($feature-queries...)Returns a query object which will result in emitting targets blocks that match any of the specified features. Passing no arguments results in no blocks being emitted.
without($feature-query)Returns a query object which will result in emitting targets blocks that do not match the specified feature.

$feature-query and $feature-queries refer to one or more of the values listed below under Supported Features.

Supported Features

MDC Web's styles are currently split according to the following features:

  • structure - All baseline styles that don't fit into any other category
  • animation - Styles responsible for causing animations and transitions to occur
  • color - Color-specific styles which rely on mdc-theme variables
  • typography - Typography-specific styles which rely on mdc-typography

Keywords

material components

FAQs

Package last updated on 28 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts