Using UnoCSS in Applet(UniApp...)

Overview

unocss-applet

Using UnoCSS in Applet(UniApp...).

Presets and Plugins

Instal

npm i unocss-applet --save-dev # with npm
yarn add unocss-applet -D # with yarn
pnpm add unocss-applet -D # with pnpm

Usage

// unocss.config.ts
import type { Preset, SourceCodeTransformer } from 'unocss'
import {
  defineConfig,
  presetAttributify,
  presetIcons,
  presetUno,
  transformerDirectives,
  transformerVariantGroup,
} from 'unocss'

import {
  presetApplet,
  presetRemToRpx,
  transformerApplet,
  transformerAttributify,
} from 'unocss-applet'

const presets: Preset[] = []
const transformers: SourceCodeTransformer[] = []

if (process.env.UNI_PLATFORM === 'h5') {
  presets.push(presetUno())
  presets.push(presetAttributify())
}
else {
  presets.push(presetApplet())
  presets.push(presetRemToRpx())

  // don't change the order
  transformers.push(transformerAttributify())
  transformers.push(transformerApplet())
}

export default defineConfig({
  presets: [
    presetIcons(),
    /**
     * you can add `presetAttributify()` here to enable unocss attributify mode prompt
     * although preset is not working for applet
     */
    // presetAttributify(),
    ...presets,
  ],
  transformers: [
    transformerDirectives(),
    transformerVariantGroup(),
    ...transformers,
  ],
})

Example

Acknowledgement

License

MIT License © 2022-PRESENT Neil Lee

Comments
  • When I remove `transformerRenameClass` , there are other problems, and the custom attributes in the class do not take effect.

    When I remove `transformerRenameClass` , there are other problems, and the custom attributes in the class do not take effect.

    1#issuecomment-1216663855

    When I remove transformerRenameClass , there are other problems, and the custom attributes in the class do not take effect.

    image

    This is the demo repo, you can have a try.

    opened by liwenfengg 10
  • Maybe new conflicts

    Maybe new conflicts

    Excellent work, compared with 'unocss-preset-uni', maybe some giant changes happened in this tool.

    However, there is a question. Before I using 'unocss-applet', the compile process could go on smoothly, after using this, an error occoured. This is screenshot:

    image

    tm-sheet is a component which I using.

    image After deleting line 24, vite could pass, but weChat miniprogram tool occured error:

    image image

    I think there may be some problems.

    By the way, an another question is does unocss has the configuration which could set individual prefix like Tailwind CSS

    image

    it may solve the conflicts between components and Unocss.

    Thanks!

    opened by LLinVIP 5
  • in app side, `shortcuts` and `Attributify Mode` Still not supported

    in app side, `shortcuts` and `Attributify Mode` Still not supported

    in app side, shortcuts and Attributify Mode Still not supported

    text="base #F2FF"

    attributify-mode

    image

    Originally posted by @liwenfengg in https://github.com/unocss-applet/unocss-applet/issues/3#issuecomment-1219093922

    enhancement 
    opened by liwenfengg 5
  • 小程序端 @apply 支持的问题(不确定是否是 bug)

    小程序端 @apply 支持的问题(不确定是否是 bug)

    使用 dark: 进行暗黑模式设计,直接使用如下写法,h5、微信和 app 端都正常:

    <button class="bg-light-blue-500 dark:bg-dark-100">
        sdfdf
      </button>
    

    可是如果使用 @apply 语法,如下

    <template>
      <button class="fff">
        sdfdf
      </button>
    </template>
    
    <style scoped>
    .fff {
      --at-apply: bg-light-blue-500 dark:bg-dark-100
    }
    </style>
    

    则,h5 和 app 正常,微信端编译出来的样式没有 dark:bg-dark-100 相关的代码导致暗黑模式匹配异常。

    不确定是否是本插件的 bug,如不是麻烦关 issue

    opened by jacksonyu 2
  • String in div or view tags generate unwanted styles

    String in div or view tags generate unwanted styles

    <div>
      py-4.5
    </div>
    

    generate

    .py-4\\\\.5{
      padding-top:1.125rem;
      padding-bottom:1.125rem;
    }
    

    We don’t need the style of this selector, and change the name directly

    opened by zguolee 0
Releases(v0.2.20)
Ed25519 signing and verification applet.

Ed25519 Applet Live demo: https://cyphr.me/ed25519_applet/ed.html This tool can run locally and offline git clone this project to a local directory. g

Cyphr.me 6 Oct 1, 2022
Onu-UI for web glassmorphism components generate by UnoCSS

Onu-UI (WIP) Onu-UI for web glassmorphism components generate by UnoCSS. Usage npm i onu-ui npm i unocss -D Add onu-ui in your main entry file. // mai

Onu-UI 197 Dec 18, 2022
(Developing) Twitter Clone made with Remix, EdgeDB & UnoCSS.

Twitter Clone Twitter clone made with Remix, EdgeDB & UnoCSS. Demo: twitter-clone.poke.dev Features Signup/Login (With GitHub OAuth) Create tweets Fol

Poke 13 Jan 3, 2023
This repo contains instructions on how to create your NFT in Solana(using Metaplex and Candy Machine) and mint it using your custom front-end Dapp

Solana-NFT minting Dapp Create your own NFT's on Solana, and mint them from your custom front-end Dapp. Tools used Metaplex -> Metaplex is the NFT sta

Udit Sankhadasariya 12 Nov 2, 2022
Using decentralized identities with Web 2 to create a no login required website. Built using the Handshake blockchain.

Blending Web 2/3, is this Web .666? ( •̀ᴗ•́ )و ̑̑ Learn more by joining the Handshake Discord Community applause is a platform I built using centraliz

Publius Federalist 13 Mar 3, 2022
Web-pack based Todo-List Website built using HTML, CSS and JavaScript. Tested Using Jest.

To-DO List Live Link Additional description about the project and its features: Built With HTML and CSS Javascript HTML & CSS3 & JavaScript Linters Gi

Saadat Ali 8 Mar 31, 2022
Tip Tweet is a hybrid dApp that provides a simple way to tip a tweet using Ethereum. Authors can claim their tips using their Twitter account. You only need the tweet URL to tip. 🚀 😎

Tip Tweet Table of Contents About Folder Structure Contract Deveopment Starting the App Usage Contributing About Tip Tweet is hybrid dApp that allows

Dias Junior 23 Nov 15, 2022
JavaScript project for the Leaderboard list app, using Webpack and ES6 features, notably modules. this app consume the Leaderboard API using JavaScript async and await and add some styling.

Leaderboard Project JavaScript project for the Leaderboard list app, using Webpack and ES6 features, notably modules. this app consume the Leaderboard

bizimungu pascal 4 May 20, 2022
This is a fully functional DAO, a Web3 project made using Solidity, Hardhat, JS, Next.js, Openzeppelin, CSS, HTML, using the Rinkerby network!

My First DAO! This is made for a DAO-Tutorial via learnweb3.io This is a DAO, a decentralised autonomous organisation, essentially a more collective a

Kell (K42) 3 Jun 20, 2022
Sample code for resizing Images with Lambda@Edge using the Custom Origin. You can deploy using AWS CDK.

Resizing Images with Lambda@Edge using the Custom Origin You can resize the images and convert the image format by query parameters. This Lambda@Edge

AWS Samples 16 Dec 11, 2022
The aim of this project is to restructure the Awesome books app code by using ES6 syntax and organising the workspace using modules.

Awesome-Books-ES6 The aim of this project is to restructure the Awesome books app code by using ES6 syntax and organising the workspace using modules.

Favour Ezeugwa 15 Aug 18, 2022
Awesome Books project with ES6 is an application that was built using Vanilla JavaScript with ES6 features like using arrow functions. This application allows you to keep records of your favorite books.

Javascript Project Awesome Books with ES6 Using Javascript to create a simple Awesome Books project. Populating the books list and then removing one b

Ghazanfar Ali 8 Sep 28, 2022
Emem Ekpo 7 Sep 9, 2022
Harrison Njuguna 5 Nov 11, 2022
A new Node.js resource built using Gatsby.js with React.js, TypeScript, and Remark.

Nodejs.dev Nodejs.dev site built using Gatsby.js with React.js, TypeScript, SCSS, and Remark. You can find the latest Figma design protype here. ?? Ge

Node.js 2.2k Jan 5, 2023
How to create an NFT on the Cardano blockchain using JavaScript

How to create an NFT on the Cardano blockchain using JavaScript Youtube Video: https://www.youtube.com/watch?v=OeOliguGn7Y Who is this guide for? For

Armada Alliance 117 Dec 31, 2022
The backend for our Airbnb App, built using Sanity.io.

AirBnb Sanity.io Backend This repository is to support my tutorial on how to build an AirBnb Clone with strucutred content using Sanity.io and Next.js

Ania Kubow 73 Dec 28, 2022
Chat app using Azure Web PubSub, Static Web Apps and other Azure services

Chatr - Azure Web PubSub Sample App This is a demonstration & sample application designed to be a simple multi-user web based chat system. It provides

Ben Coleman 55 Dec 31, 2022