trendyminds/craft-design-tokens
Composer 安装命令:
composer require trendyminds/craft-design-tokens
包简介
A Craft dropdown field powered by JSON files in your project
关键字:
README 文档
README
🤔 What is this?
Design Tokens is a Craft dropdown fieldtype where the options and the values are controllable via JSON files.
If you use Tailwind the JIT process only runs against Tailwind values it finds in your filesystem. If you have a class like bg-indigo-700 in your database there's nothing Tailwind can do to find that (unless you enable Project Config, but do you really want Tailwind crawling your Project Config?).
Design Tokens allows you to define the values within JSON files on your filesystem, making it possible to use Tailwind's JIT process and provide a simple way to add and edit new values to your dropdowns.
⚠️ Careful, though!
Editing these JSON files means it's possible to break the output of your data. For example:
{
"standard": "my-12",
+ "tighter": "my-6",
- "tight": "my-6",
"none": "my-0"
}
Changing "tight" to "tighter" would break any entry using "tight"! Now when it tries to locate the value of "tight" it will come up empty until you've changed all of those values.
📝 Usage
To setup configurations, create individual JSON files within config/designtokens.
A single key/value pair (Ex: spacing.json)
{
"standard": "my-12",
"tight": "my-6",
"none": "my-0"
}
{{ entry.myTokenField }}
{# Outputs the value of the selected option (my-12, my-6, my-0) #}
{{ entry.myTokenField.key }}
{# Outputs the key of the selected option (standard, tight, none) #}
A nested key/value pair (Ex: hero.json)
{
"red": {
"text": "text-red-500",
"bg": "bg-red-100"
},
"green": {
"text": "text-green-500",
"bg": "bg-green-100"
},
"blue": {
"text": "text-blue-500",
"bg": "bg-blue-100"
}
}
{{ entry.myTokenField.key }}
{# Outputs the key of the selected option (red, green, blue) #}
{{ entry.myTokenField.get('text') }}
{# Outputs the nested value of the selected option (text-red-500, text-green-500, text-blue-500) #}
{{ entry.myTokenField.get('bg') }}
{# Outputs the nested value of the selected option (bg-red-100, bg-green-100, bg-blue-100) #}
You can also call a config directly without interface with a field.
{# Get the spacing.json config #} {{ designTokens('spacing') }} {# Get the value from the `standard` key #} {{ designTokens('spacing').standard }} {# Get the value from the `tight` key #} {{ designTokens('spacing').tight }} {# Get the value from the `none` key #} {{ designTokens('spacing').none }}
🪄 Example
Rather than using many Twig conditions to render the properly selected colors you can use Design Tokens to easily pluck the value you need and insert the class into your respective HTML.
📦 Installing
Install Design Tokens in one of two ways:
- Install via Craft's Plugin Store
- Run
composer require trendyminds/design-tokensand enable the plugin from "Settings > Plugins"
🤝 Contributing
If you'd like to contribute please submit a pull request for review. We try to review and accept contributions whenever possible!
trendyminds/craft-design-tokens 适用场景与选型建议
trendyminds/craft-design-tokens 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.27k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2022 年 07 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「Craft」 「craft cms」 「token field」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 trendyminds/craft-design-tokens 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 trendyminds/craft-design-tokens 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 trendyminds/craft-design-tokens 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Expand, collapse, change the status of, or delete multiple blocks in a Matrix field simultaneously.
GraphQL authentication for your headless Craft CMS applications.
Set Links with a specific language parameter
Supercharged text field validation.
A package for validating Google Cloud's JWT provided by webhooks
JSON Web Token Authentication for Laravel and Lumen
统计信息
- 总下载量: 3.27k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 18
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-07-08
