Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.x] Replicator "add set" button label option #9806

Merged
merged 5 commits into from May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 12 additions & 2 deletions resources/js/components/fieldtypes/replicator/AddSetButton.vue
Expand Up @@ -3,14 +3,23 @@
<div class="replicator-set-picker">
<set-picker :enabled="enabled" :sets="groups" @added="addSet">
<template #trigger>
<div class="replicator-set-picker-button-wrapper">
<button v-if="enabled" class="btn-round flex items-center justify-center" :class="{ 'h-5 w-5': ! last }" @click="addSetButtonClicked">
<div class="replicator-set-picker-button-wrapper flex items-center ">
<button
v-if="enabled"
class="btn-round flex items-center justify-center"
:class="{
'h-5 w-5': ! last,
'mr-2': label.length > 0,
}"
@click="addSetButtonClicked"
>
<svg-icon name="micro/plus"
:class="{
'w-3 h-3 text-gray-800 dark:text-dark-175 group-hover:text-black dark:group-hover:dark-text-100': last,
'w-2 h-2 text-gray-700 dark:text-dark-200 group-hover:text-black dark:group-hover:dark-text-100 transition duration-150': !last
}" />
</button>
<span class="text-sm dark:text-dark-175">{{ label }}</span>
</div>
</template>
</set-picker>
Expand All @@ -33,6 +42,7 @@ export default {
index: Number,
last: Boolean,
enabled: { type: Boolean, default: true },
label: String,
},

methods: {
Expand Down
Expand Up @@ -98,6 +98,7 @@
:groups="groupConfigs"
:sets="setConfigs"
:index="value.length"
:label="config.button_label"
@added="addSet" />

</section>
Expand Down
1 change: 1 addition & 0 deletions resources/lang/en/fieldtypes.php
Expand Up @@ -129,6 +129,7 @@
'range.config.step' => 'The minimum size between values.',
'range.title' => 'Range',
'relationship.config.mode' => 'Choose your preferred UI style.',
'replicator.config.button_label' => 'Add a label to the add set button.',
'replicator.config.collapse' => 'The set collapsing behavior.',
'replicator.config.collapse.accordion' => 'Only allow one set to be expanded at a time',
'replicator.config.collapse.disabled' => 'All sets expanded by default',
Expand Down
6 changes: 6 additions & 0 deletions src/Fieldtypes/Replicator.php
Expand Up @@ -54,6 +54,12 @@ protected function configFieldItems(): array
'type' => 'toggle',
'default' => true,
],
'button_label' => [
'display' => __('Add Set Label'),
'instructions' => __('statamic::fieldtypes.replicator.config.button_label'),
'type' => 'text',
'default' => '',
],
],
],
[
Expand Down