Skip to content

Conversation

@LucaMimmo05
Copy link
Contributor

No description provided.

@LucaMimmo05 LucaMimmo05 requested a review from Byloth as a code owner June 11, 2025 12:24
Copy link
Owner

@Byloth Byloth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ti ho lasciato un po' di commenti.
Correggi - correttamente - la PR prima ch'io esegua il merge.

import ClayDropdown from "./ClayDropdown.vue";
import type { Meta, StoryObj } from "@storybook/vue3";

const meta: Meta<typeof ClayDropdown> = {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Utilizza la stessa struttura degli altri file.
Definisci un'interfaccia con quelle che sono le proprietà da gestire.

export default meta;
type Story = StoryObj<typeof meta>;

export const Default: Story = {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gestisci la storia come quella degli altri file.
Aggiungi il metodo render e il template in cui vengono settate le proprietà correttamente.

}
};

export const WithSelection: Story = {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non è una variante.

}
};

export const WithLongText: Story = {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avrebbe - anche - avuto senso come variante se ci fossero state delle differenze a livello di stile o di classi...
Ma se l'unica differenza è la lunghezza del testo delle opzioni, non è una variante.

modelValue?: string;
}

const props = withDefaults(defineProps<Props>(), {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alcuni suggeriscono di usare il defineProps wrappato dal metodo withDefault.
Io non sono d'accordo: mi sembra solo una "soluzione" ad un problema che - in realtà - non esiste.

In Vue le proprietà si possono definire in una sola chiamata, senza definire alcuna interfaccia extra, usando correttamente il metodo defineProps.
Guarda negli altri file come funziona.

const selectItem = (item: { label: string; value: string }) =>
{
selectedValue.value = item.value;
emit("update:modelValue", item.value);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Qui - di conseguenza - usando il defineModel non dovrai emettere più alcun evento.
Ti basterà modificarne il valore:

value.value = item.value;

Ricordati di rimuovere le proprietà e le variabili che non saranno più utilizzate.

$dropdown-color-background-dark: #2c2e30;
$dropdown-color-background-hover-dark: rgba(42, 42, 42, 0.9);
$dropdown-color-outline-dark: color.complement($dropdown-color-background-dark);
$dropdown-color-shadow-dark: color.adjust($dropdown-color-background-dark, $lightness: -30%);
Copy link
Owner

@Byloth Byloth Jun 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Le variabili SCSS non devono più essere usate.


@media (prefers-color-scheme: dark) {
.clay-dropdown {
background-color: var(--clay-dropdown-color-background-dark);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Le variabili CSS servono per poter essere usate anche in maniera dinamica.

Se io dovessi definire:

:root
{
    --clay-dropdown-color-background: white;
    --clay-dropdown-shadow: inset 0 2px 5.1px 0 rgba(0, 0, 0, 0.25),
                            0 2px 4px 0 rgba(142, 138, 138, 0.75);
}
.clay-dropdown
{
    background-color: var(--clay-dropdown-color-background);
    box-shadow: var(--clay-dropdown-shadow);
    
    &:focus
    {
        --clay-dropdown-shadow: inset 0 2px 5.1px 0 rgba(0, 0, 0, 0.35),
                                0 2px 4px 0 rgba(142, 138, 138, 0.85);
    }
}

@media (prefers-color-scheme: dark)
{
    :root
    {
        --clay-dropdown-color-background: black;
        --clay-dropdown-shadow: inset 0 3px 8px 0 rgba(0, 0, 0, 0.6),
                                0 3px 6px 0 rgba(0, 0, 0, 0.4);
    }
    .clay-dropdown
    {
        &:focus
        {
            --clay-dropdown-shadow: inset 0 4px 10px 0 rgba(0, 0, 0, 0.7),
                                    0 4px 8px 0 rgba(0, 0, 0, 0.5);
        }
    }
}

Il colore di background cambierebbe correttamente, senza risovrascrivere alcuna regola CSS.
Stessa cosa accadrebbe per la shadow, che cambierebbe correttamente.


Correggi l'uso di tutte questa variabili.
Prendi spunto dagli altri file già fatti; lì è già stato implementato correttamente.

--clay-dropdown-transition-duration-instant: 0.1s;
--clay-dropdown-transition-timing: cubic-bezier(0.4, 0, 0.2, 1);
--clay-dropdown-transition-timing-out: ease-out;
}
Copy link
Owner

@Byloth Byloth Jun 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ho il vago sentore che molte di queste variabili CSS non dovrebbero aver ragione di esistere.

Controlla il commento precedente.

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

Successfully merging this pull request may close these issues.

2 participants