0.11.5 • Published 6 months ago

@wowjob/yacss v0.11.5

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

YACSS – The Zero-Build-Time, Flexible CSS Utility Library

Welcome to YACSS! This library is designed to bring simplicity, speed, and flexibility to your styling workflow. Whether you’re building with vanilla JS, HTML/CSS, React, Next.js, Vite, Astro, or any other framework or library, YACSS will slip in seamlessly with zero build time or extra configuration.

If you know CSS, you already know how to use YACSS. Gone are the days of steep learning curves, complicated configuration files, or puzzling build steps. In just 1–2 minutes, you can get up and running with a mobile-first approach for responsive web design (RWD), an outstanding developer experience (DX), and a supercharged debugging workflow (thank you, autocomplete!). This README is your comprehensive guide, designed to help you kickstart your journey with YACSS.


Table of Contents

  1. Key Features
  2. Why YACSS?
  3. Installation
  4. Getting Started
  5. Usage Examples
  6. API Overview
  7. Tips & Tricks
  8. FAQ
  9. Roadmap
  10. Contributing
  11. License

Key Features

  • Zero Build Time
    No bundlers, no watchers—just drop in YACSS and go. Use your favorite tools without adding any extra step in your CI or local dev environment.

  • Works with Any Framework or Library
    Enjoy using YACSS in Vanilla JS, HTML/CSS, React, Next.js, Vite, Astro, Svelte, Vue, or even a homegrown setup.

  • Best DX and Debugging Experience
    Autocomplete your CSS properties (depending on your editor/IDE) and debug with minimal overhead. Work the same way you do in regular CSS.

  • Mobile-First Approach
    All your styles adapt seamlessly to different devices. Design for the smallest screens first, and then add desktop (or any other device) overrides.

  • Minimal to No Configuration
    YACSS doesn’t require complicated config files. Just install and start styling. It’s that easy.

  • 1–2 Minutes to Learn
    If you know CSS, you already know YACSS. Transition from standard CSS or other utility-based libraries with minimal friction.

  • Flexible and Extensible
    The library is designed to let you easily compose class names or inline styles. Extend or customize it as you see fit.

  • Works with Client & Server Components
    Perfect for universal JavaScript ecosystems—no matter where your components are rendered.

  • Utility to Return Class Names and Styles
    Concentrate on creating style data. Let YACSS generate the right classes and inline styles automatically.


Why YACSS?

YACSS strikes a balance between utility-first and classic CSS. By providing an intuitive API that aligns with how you already write your styles, YACSS helps you:

  • Write Less, Do More: Eliminate boilerplate code.
  • Focus on Design: Stop wrestling with build configs.
  • Move Quickly: Achieve more in less time.

No matter how large or small your project is, YACSS is a safe, scalable choice that suits everything from prototypes to production builds.


Installation

Pick your favorite package manager:

# npm
npm install @wowjob/yacss

# bun
bun install @wowjob/yacss

# pnpm
pnpm install @wowjob/yacss

That’s it. You’re good to go—no additional setup required.


Getting Started

  1. Install YACSS with your favorite package manager (see Installation).
  2. Import one of the provided CSS files (reset.css, all.css, or all.min.css) in your entry point (e.g., index.js or layout.tsx in Next.js).
  3. Utilize the getStyle utility to effortlessly transform your style definitions into class names and inline styles.

Usage Examples

Zero Configuration

All you need is to import the base resets and (optionally) the global styles. You can do this in any framework without additional setup. For instance, in a plain HTML file:

<!-- index.html -->
<html>
  <head>
    <link rel="stylesheet" href="node_modules/@wowjob/yacss/reset.css" />
    <link rel="stylesheet" href="node_modules/@wowjob/yacss/all.css" />
  </head>
  <body>
    <div id="app">Hello World!</div>
    <script type="module">
      import { getStyle } from './node_modules/@wowjob/yacss/index.js';
      // use getStyle here...
    </script>
  </body>
</html>

No bundler or special config needed—zero build time.

Mobile-First Responsiveness

Define your mobile and desktop style properties separately. YACSS merges them internally for a seamless responsive layout:

import { getStyle } from '@wowjob/yacss';

const { className, style } = getStyle({
  mobile: {
    padding: '10px',
    backgroundColor: 'lightblue',
  },
  desktop: {
    padding: '20px',
    backgroundColor: 'lightgreen',
  },
});

// Use 'className' and 'style' in your JSX or standard HTML

Working with Next.js

Below is a typical Next.js layout.tsx example that demonstrates how to import YACSS CSS and apply styles:

// layout.tsx
import '@wowjob/yacss/reset.css'
// development version
import '@wowjob/yacss/all.css'
// production version
// import '@wowjob/yacss/all.min.css'
import type { ReactNode } from 'react'

const RootLayout = ({
  children,
}: Readonly<{
  children: ReactNode
}>) => {
  return (
    <html lang="en">
      <body>{children}</body>
    </html>
  )
}

export default RootLayout

Then in your page component:

// page.tsx or Home.tsx
import { getStyle } from '@wowjob/yacss';

export default function Home() {
  const { className, style } = getStyle({
    mobile: {
      border: {
        width: 4,
        style: 'dotted',
        color: 'blue',
      },
      padding: 20,
    },
    env: 'prod',
  });

  return (
    <div>
      <div className={className} style={style}>
        <h1>Simple example</h1>
        <div
          {...getStyle({
            mobile: {
              border: '8px solid pink',
              padding: 80,
            },
            env: 'prod',
          })}
        >
          <h2>It gets better</h2>
          <div
            {...getStyle({
              mobile: {
                border: '4px solid red',
                padding: 16,
              },
              desktop: {
                border: '12px solid green',
                padding: 32,
                borderRadius: 20,
              },
              env: 'prod',
            })}
          >
            <h3>Happy coding!</h3>
          </div>
        </div>
      </div>
    </div>
  );
}

This example shows how straightforward it is to integrate YACSS in a modern setup.


API Overview

The core of YACSS is the getStyle function:

getStyle(config)

  • config: An object specifying style properties for different breakpoints or environments.

getStyle returns an object containing:

  • className: A string of class names automatically generated from your style definitions.
  • style: Inline style declarations.

You can apply these to JSX elements using the React spread operator:

<div {...getStyle({ mobile: { padding: '10px' } })} />

Or by destructuring:

const { className, style } = getStyle({ mobile: { margin: '1rem' } });
<div className={className} style={style} />

Note: The exact structure of config can accommodate advanced usage, including nested objects, shorthands, or environment-specific logic.


Tips & Tricks

  1. Focus on Mobile First: Under the mobile key, define your base styles. Then override under desktop, tablet, or any other custom breakpoint if you prefer.
  2. Production vs. Development:
    • Development: Use all.css for human-readable class names and easier debugging.
    • Production: Use all.min.css for compressed class names to optimize performance.
  3. Dynamic Styles: You can dynamically generate styles based on state or props—just call getStyle inside your functional components or hooks.
  4. No Rebuild: Since YACSS works out of the box, you don’t need to wait for a bundler or dev server to recompile style changes.

FAQ

Q: Do I need PostCSS, Webpack, or any build tool?
A: Not at all. YACSS is designed to be used with zero build configuration—just install and import.

Q: Can I override or extend the provided resets and global styles?
A: Yes, simply create your own CSS file and import it after reset.css and all.css to override default rules.

Q: Does it support server-side rendering (SSR)?
A: Absolutely. YACSS works flawlessly in SSR setups (e.g., Next.js or custom Node.js servers), and it’s safe to use in both client and server components.


Roadmap

  • Additional Breakpoint Support: Let developers define custom breakpoints on the fly.
  • TypeScript Enhancements: Expand types for even better IntelliSense and autocomplete.
  • Plugin Ecosystem: Provide a standard way to create community-driven plugins and enhancers.

Stay tuned for updates and community contributions!


Contributing

We welcome contributions of all kinds:

  • Bug Reports & Feature Requests: Use the issue tracker on the repo.
  • Pull Requests: Fork the project, make changes, and submit a PR.
  • Feedback: Share your use cases and suggestions. We’re always listening.

License

YACSS is licensed under the MIT License. Feel free to use it in personal and commercial projects. Refer to the LICENSE file in the repository for more details.


Thank you for using YACSS. We hope it simplifies your styling and boosts productivity. If you have any questions, suggestions, or simply want to share what you built, feel free to reach out or open a PR. Happy coding!

0.9.56

6 months ago

0.9.57

6 months ago

0.9.58

6 months ago

0.9.59

6 months ago

0.9.52

6 months ago

0.9.53

6 months ago

0.9.54

6 months ago

0.9.55

6 months ago

0.9.50

6 months ago

0.9.51

6 months ago

0.9.45

6 months ago

0.9.46

6 months ago

0.9.47

6 months ago

0.9.48

6 months ago

0.9.41

6 months ago

0.9.42

6 months ago

0.9.43

6 months ago

0.9.44

6 months ago

0.9.49

6 months ago

0.9.40

6 months ago

0.9.8

6 months ago

0.9.35

6 months ago

0.9.7

6 months ago

0.9.36

6 months ago

0.9.37

6 months ago

0.9.9

6 months ago

0.9.30

6 months ago

0.9.4

6 months ago

0.9.31

6 months ago

0.9.3

6 months ago

0.9.32

6 months ago

0.9.6

6 months ago

0.9.33

6 months ago

0.9.5

6 months ago

0.9.38

6 months ago

0.9.39

6 months ago

0.10.9

6 months ago

0.10.2

6 months ago

0.10.4

6 months ago

0.10.5

6 months ago

0.10.6

6 months ago

0.10.7

6 months ago

0.10.8

6 months ago

0.9.100

6 months ago

0.9.26

6 months ago

0.9.27

6 months ago

0.9.28

6 months ago

0.9.29

6 months ago

0.9.110

6 months ago

0.9.112

6 months ago

0.9.111

6 months ago

0.9.96

6 months ago

0.9.97

6 months ago

0.9.98

6 months ago

0.9.99

6 months ago

0.10.18

6 months ago

0.10.19

6 months ago

0.10.14

6 months ago

0.9.92

6 months ago

0.10.15

6 months ago

0.9.106

6 months ago

0.9.93

6 months ago

0.10.16

6 months ago

0.9.109

6 months ago

0.9.94

6 months ago

0.10.17

6 months ago

0.9.108

6 months ago

0.9.95

6 months ago

0.10.10

6 months ago

0.9.103

6 months ago

0.10.11

6 months ago

0.9.102

6 months ago

0.10.12

6 months ago

0.9.90

6 months ago

0.10.13

6 months ago

0.9.104

6 months ago

0.9.91

6 months ago

0.9.89

6 months ago

0.9.120

6 months ago

0.9.123

6 months ago

0.10.20

6 months ago

0.9.122

6 months ago

0.9.85

6 months ago

0.9.86

6 months ago

0.9.87

6 months ago

0.9.88

6 months ago

0.10.29

6 months ago

0.10.25

6 months ago

0.9.118

6 months ago

0.10.26

6 months ago

0.9.117

6 months ago

0.9.82

6 months ago

0.10.27

6 months ago

0.10.28

6 months ago

0.9.119

6 months ago

0.9.84

6 months ago

0.10.21

6 months ago

0.10.22

6 months ago

0.9.113

6 months ago

0.10.23

6 months ago

0.9.116

6 months ago

0.10.24

6 months ago

0.9.115

6 months ago

0.9.132

6 months ago

0.9.131

6 months ago

0.9.79

6 months ago

0.10.30

6 months ago

0.9.134

6 months ago

0.10.31

6 months ago

0.10.36

6 months ago

0.9.129

6 months ago

0.9.70

6 months ago

0.10.37

6 months ago

0.9.128

6 months ago

0.9.71

6 months ago

0.10.38

6 months ago

0.9.72

6 months ago

0.10.39

6 months ago

0.10.32

6 months ago

0.9.125

6 months ago

0.10.33

6 months ago

0.10.34

6 months ago

0.10.35

6 months ago

0.9.143

6 months ago

0.9.67

6 months ago

0.9.142

6 months ago

0.9.69

6 months ago

0.9.63

6 months ago

0.9.64

6 months ago

0.9.141

6 months ago

0.9.65

6 months ago

0.9.140

6 months ago

0.9.60

6 months ago

0.9.61

6 months ago

0.9.62

6 months ago

0.9.136

6 months ago

0.9.138

6 months ago

0.9.137

6 months ago

0.9.12

6 months ago

0.8.45

6 months ago

0.9.13

6 months ago

0.8.44

6 months ago

0.9.14

6 months ago

0.8.47

6 months ago

0.9.15

6 months ago

0.8.46

6 months ago

0.8.41

6 months ago

0.8.40

6 months ago

0.9.10

6 months ago

0.8.43

6 months ago

0.9.11

6 months ago

0.8.42

6 months ago

0.9.16

6 months ago

0.9.17

6 months ago

0.9.18

6 months ago

0.9.19

6 months ago

0.11.0

6 months ago

0.11.1

6 months ago

0.11.2

6 months ago

0.11.3

6 months ago

0.11.4

6 months ago

0.11.5

6 months ago

0.8.34

6 months ago

0.8.33

6 months ago

0.8.36

6 months ago

0.8.35

6 months ago

0.8.32

6 months ago

0.8.38

6 months ago

0.8.37

6 months ago

0.8.39

6 months ago

0.9.0

6 months ago

0.9.2

6 months ago

0.9.1

6 months ago

0.8.31

6 months ago

0.8.30

6 months ago

0.8.29

6 months ago

0.8.28

6 months ago

0.8.27

6 months ago

0.8.26

6 months ago

0.8.25

6 months ago

0.8.24

6 months ago

0.8.23

6 months ago

0.8.22

6 months ago

0.8.21

6 months ago

0.8.20

6 months ago

0.8.19

6 months ago

0.8.18

6 months ago

0.8.17

6 months ago

0.8.16

6 months ago

0.8.15

6 months ago

0.8.14

6 months ago

0.8.13

6 months ago

0.8.12

6 months ago

0.8.11

6 months ago

0.8.10

6 months ago

0.8.9

6 months ago

0.8.8

6 months ago

0.8.7

6 months ago

0.8.6

6 months ago

0.8.5

6 months ago

0.8.4

6 months ago

0.8.3

7 months ago

0.8.2

7 months ago

0.8.1

7 months ago

0.8.0

7 months ago

0.7.0

7 months ago

0.6.6

7 months ago

0.6.5

7 months ago

0.6.4

7 months ago

0.6.3

7 months ago

0.6.2

7 months ago

0.6.0

7 months ago

0.5.0

7 months ago

0.4.5

7 months ago

0.4.4

7 months ago

0.4.3

7 months ago

0.4.2

7 months ago

0.4.1

7 months ago

0.4.0

7 months ago

0.3.1

7 months ago

0.3.0

7 months ago

0.2.2

7 months ago

0.2.1

7 months ago

0.2.0

7 months ago

0.1.1

7 months ago

0.1.0

7 months ago

0.0.7

7 months ago

0.0.6

7 months ago

0.0.5

7 months ago

0.0.4

7 months ago

0.0.3

7 months ago

0.0.2

7 months ago