jacerider/neo_icon

基于IconMoon的图标管理器。

安装: 37

依赖: 2

建议: 0

安全: 0

星标: 0

关注者: 1

分支: 0

开放问题: 0

类型:drupal-module

1.0.6 2024-09-12 21:07 UTC

This package is auto-updated.

Last update: 2024-09-12 21:08:34 UTC


README

  • 介绍
  • 要求
  • 安装
  • 在PHP中使用
  • 在SCSS中使用
  • 图标定义

INTRODUCTION

允许在Drupal中使用Icomoon图标包。

REQUIREMENTS

此模块不依赖于Drupal核心之外的任何模块。

INSTALLATION

按照通常安装贡献的Drupal模块的方式进行安装。有关更多信息,请访问https://www.drupal.org/node/1897420

USAGE WITHIN SCSS

提供了一个PHP特质,可以作为Drupal核心StringTranslationTrait的替代品。

use Drupal\neo_icon\IconTranslationTrait;

// Dynamic icon using icon repository.
$this->icon('Angel');
// Specific icon by name using weighted library match.
$this->icon('Angel', 'drupal');
// Specific icon by name from specific library (if published). If library does
// not exist or is not published, a weighted library match will be used.
$this->icon('Angel', 'drupal', 'solid');
// Supplying a prefix will filter the dynamic icon repository lookup to only
// those definitions that support that prefix. It allows, for example, an icon
// to be scoped to only be available in the admin.
$this->icon('Angel', NULL, NULL, ['admin']);
// If you want to get an get a dynamic icon regardless of the prefix, you can
// pass 'any' as the prefix.
$this->icon('Angel', NULL, NULL, ['all']);

USAGE WITHIN SCSS

全局图标集可以直接通过mixin在.scss文件中使用。

@use 'neo-icon';

@include neo-icon.icon('drupal', before);
@include neo-icon.icon('drupal', after);

此mixin故意只使用图标名称并忽略库。这允许在不重命名图标的情况下更换不同的图标库。如果两个库都包含具有相同名称的图标,则可能导致冲突,并在标记为全局时显示。

ICON DEFINITIONS

可以通过MODULE_NAME.neo.icon.yml文件定义动态图标。

# A definition that will match any string starting with "drupal".
drupal.start:
  start: icon
  icon: drupal
# A definition that will match any string ending with "drupal".
drupal.end:
  end: icon
  icon: drupal
# A definition that will match any string containing the word "drupal".
drupal.word:
  word: icon
  icon: drupal
# A definition that will match the exact string "drupal".
drupal.exact:
  exact: icon
  icon: drupal
# A weight can be added to the definition to control their lookup order.
drupal.weight:
  exact: icon
  icon: drupal
  weight: 10
# A definition with a prefix. Prefix can also be an array of strings.
drupal.prefix:
  start: icon
  icon: drupal
  prefix: admin