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

Passing css classes through to components #60

Open
tnorthcutt opened this issue Nov 18, 2024 · 1 comment
Open

Passing css classes through to components #60

tnorthcutt opened this issue Nov 18, 2024 · 1 comment

Comments

@tnorthcutt
Copy link

It seems like it would be really handy to be able to pass CSS classes through to components. E.g. in nova-settings-tool.php being able to do this:

[
    'key' => 'setting_1',
    'label' => 'Custom delay setting',
    'type' => 'select',
    'options' => [
        '0' => 'No Delay',
        '7' => '1 Week',
        '14' => '2 Weeks',
        '21' => '3 Weeks',
        '28' => '4 Weeks',
    ],
    'classes' => ['form-input', 'whatever-other-classes'],
    'panel' => 'Customers',
];

And then in SelectSetting.vue (for this example) having (note the :class line added):

<select
    :id="setting.key"
    :value="setting.value"
    @change="
        $emit('update', {
            key: setting.key,
            value: $event.target.value,
        })
    "
    class="w-full block form-control form-select form-select-bordered"
    :class="setting.classes"
>
    <option value="" selected>{{ setting.placeholder || __('Choose an option') }}</option>
    <option v-for="(label, option) in setting.options" :key="option" :value="option">
        {{ __(label) }}
    </option>
</select>

But, maybe there's a reason for not doing this that I haven't thought of. Is this something you'd be open to adding support for?

@tnorthcutt
Copy link
Author

FWIW, in the meantime I forked this for our internal use, made the change, and it works great. Happy to PR the change if you'd like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant