import { defineConfig, presetIcons } from 'unocss'

// https://github.com/MellowCo/unocss-preset-weapp
import presetWeapp from 'unocss-preset-weapp'
import { defaultAttributes, extractorAttributify, transformerClass } from 'unocss-preset-weapp/transformer'

const { presetWeappAttributify, transformerAttributify } = extractorAttributify({
    attributes: [...defaultAttributes, 'icon'],
})

export default defineConfig({
    shortcuts: [
        {
            'border-base': 'border border-[#eee]',
            'flex-center': 'flex justify-center items-center',
            ellipsis: 'text-ellipsis whitespace-nowrap overflow-hidden',
        },
    ],
    presets: [
        // https://github.com/MellowCo/unocss-preset-weapp
        presetWeapp(),
        // autocomplete attributes
        presetWeappAttributify(),
        // icon
        presetIcons({
            prefix: ['i-', 'icon-'],
            extraProperties: {
                display: 'inline-flex',
            },
        }),
    ],
    transformers: [
        // https://github.com/MellowCo/unocss-preset-weapp/tree/main/src/transformer/transformerAttributify
        transformerAttributify(),

        // https://github.com/MellowCo/unocss-preset-weapp/tree/main/src/transformer/transformerClass
        transformerClass(),
    ],
})
