goldnead / statamic-collapse-fieldtype
Statamic 的折叠字段类型,可以美观地隐藏和显示您的字段。
v1.1
2024-07-11 09:27 UTC
Requires
- php: ^7.3|^8.0|^8.1|^8.2|^8.3
- statamic/cms: 3.* | 4.* | 5.*
README
Statamic 的折叠字段类型,可以美观地隐藏和显示您的字段。
就这么简单。只需将所有占用过多空间或不想让客户混淆的字段收起来,voilà:在任何您想要的位置创建一个美观的折叠内容区域,以隐藏臃肿的字段。
安装
composer require goldnead/statamic-collapse-fieldtype
就是这样。无需关注供应商资产或等待配置的配置文件。只是一个简单的字段类型,没有其他。
使用
幕后,这个字段类型有点像 grid
或 replicator
字段类型。只是没有重复。甚至条件也适用!只需像这样在字段集或蓝图中使用它
title: 'Content Theme' fields: - handle: collapse field: fields: - handle: toggle_field field: default: false display: 'Test conditional fields!' type: toggle icon: toggle width: 50 listable: hidden - handle: advanced_settings field: display: 'Advanced Settings' type: section icon: section listable: hidden if: toggle_field: 'equals true' - handle: section_width field: options: sm: SM md: MD lg: LG custom: Custom default: md display: 'Section Width' type: button_group icon: button_group width: 75 listable: hidden - handle: custom_width field: default: '450' display: 'Custom Width' type: integer icon: integer width: 25 listable: hidden if: section_width: 'equals custom' display: 'Collapse This!' type: collapse icon: asection listable: hidden instructions: "When you click here, something great will happen."
简单易行,对吧?您也可以在蓝图编辑器中使用它。
模板
就像在 grid
字段集中一样,所有值都在该字段的作用域内。所以要从上面的示例中访问变量 section_width
,我们需要在模板中写点像这样的事情
<section width="{{ collapse:section_width }}>...</section>
待办事项
- 热情地添加了对与 radnight 一起使用的暗黑模式的支持。需要找出如何在只有那种类型的插件被使用时才使用暗黑模式。否则,当其他一切保持明亮时,它将显示为暗黑,真讨厌!