dd/evolutioncms-snippets-ddcolortools 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

dd/evolutioncms-snippets-ddcolortools

Composer 安装命令:

composer require dd/evolutioncms-snippets-ddcolortools

包简介

Converts the color to match the offset in tone, brightness, or saturation.

README 文档

README

Converts the color to match the offset in tone, brightness, or saturation.

Requires

Installation

Manually

1. Elements → Snippets: Create a new snippet with the following data

  1. Snippet name: ddColorTools.
  2. Description: <b>3.2.1</b> Converts the color to match the offset in tone, brightness, or saturation..
  3. Category: Core.
  4. Parse DocBlock: no.
  5. Snippet code (php): Insert content of the ddColorTools_snippet.php file from the archive.

2. Elements → Manage Files

  1. Create a new folder assets/snippets/ddColorTools/.
  2. Extract the archive to the folder (except ddColorTools_snippet.php).

Using (MODX)EvolutionCMS.libraries.ddInstaller

Just run the following PHP code in your sources or Console:

//Include (MODX)EvolutionCMS.libraries.ddInstaller
require_once(
	$modx->getConfig('base_path') .
	'assets/libs/ddInstaller/require.php'
);

//Install (MODX)EvolutionCMS.snippets.ddColorTools
\DDInstaller::install([
	'url' => 'https://github.com/DivanDesign/EvolutionCMS.snippets.ddColorTools',
	'type' => 'snippet'
]);
  • If ddColorTools is not exist on your site, ddInstaller will just install it.
  • If ddColorTools is already exist on your site, ddInstaller will check it version and update it if needed.

Parameters description

Input color

  • inputColor

    • Desctription: Input color as HEX, HSL or HSB/HSV, with or without alpha-channel.
      Case-insensitive.
      Valid format examples:
      • ffffff
      • #FFFFFF
      • #FFFFFFFF
      • hsl(0, 0%, 100%)
      • hsla(0, 0%, 100%)
      • HSL(0, 0, 100)
      • hsb(0, 0%, 100%)
      • hsba(0, 0%, 100%)
      • hsv(0, 0%, 100%)
      • hsva(0, 0%, 100%)
      • hsb(0, 0, 100)
      • hsv(0, 0, 100)
    • Valid values: string
    • Required
  • inputColor_docField

    • Desctription: The name of the document field / TV which value is required to get.
      If the parameter is passed then the input string will be taken from the field / TV and inputColor will be ignored.
    • Valid values: string
    • Default value: —
  • inputColor_docId

    • Desctription: ID of the document which field/TV value is required to get.
      inputColor_docId equals the current document id since inputString_docId is unset.
    • Valid values: integer
    • Default value: —

Color modification

All parameters can contain the following special operators:

  1. + (e. g. +10) — plus
  2. - (e. g. -10) — minus
  3. abs — round to max or min value
  4. r — invert
  5. without operator (e. g. 10) — just set equal to
  • offset_h

    • Desctription: Operations of the hue offset separated by commas.
    • Valid values: stringCommaSeparated
    • Default value: '+0'
  • offset_h[i]

    • Desctription: Offset of the hue in degrees ([-360; +360]).
    • Valid values: string
    • Required
  • offset_s

    • Desctription: Operations of the saturation offset separated by commas.
    • Valid values: stringCommaSeparated
    • Default value: '+0'
  • offset_s[i]

    • Desctription: Offset of the saturation in persents ([-100; +100]).
    • Valid values: string
    • Required
  • offset_l

    • Desctription: Operations of the lightness offset separated by commas.
    • Valid values: stringCommaSeparated
    • Default value: '+0'
  • offset_l[i]

    • Desctription: Offset of the lightness in persents ([-100; +100]).
    • Valid values: string
    • Required
  • offset_a

    • Desctription: Operations of the alpha-channel offset separated by commas.
    • Valid values: stringCommaSeparated
    • Default value: '+0'
  • offset_a[i]

    • Desctription: Offset of the alpha-channel in persents ([-100; +100]).
    • Valid values: string
    • Required

Output

  • result_outputFormat

    • Desctription: Output color format.
      Case-insensitive.
    • Valid values:
      • 'hex'
      • 'hsl'
      • 'rgb'
    • Default value: 'hsl'
  • result_tpl

    • Desctription: Chunk to parse result.
      Available placeholders:
      • [+ddResult+] — full color string
      • [+ddH+] — hue
      • [+ddS+] — saturation
      • [+ddL+] — lightness
      • [+ddA+] — alpha-channel
      • [+ddIsDark+] — is color dark (0 || 1)?
    • Valid values:
      • stringChunkName
      • string — use inline templates starting with @CODE:
    • Default value: —
  • result_tpl_placeholders

    • Desctription: Additional data has to be passed into the result_tpl.
      Nested objects and arrays are supported too:
      • {"someOne": "1", "someTwo": "test" } => [+someOne+], [+someTwo+].
      • {"some": {"a": "one", "b": "two"} } => [+some.a+], [+some.b+].
      • {"some": ["one", "two"] } => [+some.0+], [+some.1+].
    • Valid values:
      • stringJsonObject — as JSON
      • stringHjsonObject — as HJSON
      • stringQueryFormatted — as Query string
      • It can also be set as a native PHP object or array (e. g. for calls through $modx->runSnippet):
        • arrayAssociative
        • object
    • Default value: —

Examples

Set black or white font color depending on background color

We need black texts in light backgrounds and vice versa.

Let's pass background color as inputColor to the snippet:

color: [[ddColorTools?
	&inputColor=`#007cc3`
	&result_tpl=`blackOrWhiteColor`
]];

Code of the blackOrWhiteColor chunk:

hsl(0, 0%, [[ddIf?
	&operand1=`[+ddIsDark+]`
	&operator=`bool`
	&trueChunk=`100`
	&falseChunk=`0`
]]%)

Run the snippet through \DDTools\Snippet::runSnippet without DB and eval

//Include (MODX)EvolutionCMS.libraries.ddTools
require_once(
	$modx->getConfig('base_path') .
	'assets/libs/ddTools/modx.ddtools.class.php'
);

//Run (MODX)EvolutionCMS.snippets.ddColorTools
\DDTools\Snippet::runSnippet([
	'name' => 'ddColorTools',
	'params' => [
		'inputColor' => '#000000',
		'result_tpl' => 'colorTpl'
	]
]);

Links

dd/evolutioncms-snippets-ddcolortools 适用场景与选型建议

dd/evolutioncms-snippets-ddcolortools 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 05 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「modx」 「MODX Evo」 「evo」 「modx evolution」 「evo cms」 「evolutioncms」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 dd/evolutioncms-snippets-ddcolortools 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 dd/evolutioncms-snippets-ddcolortools 我们能提供哪些服务?
定制开发 / 二次开发

基于 dd/evolutioncms-snippets-ddcolortools 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 2
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 5
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2020-05-08