Giter Club home page Giter Club logo

classcat's People

Contributors

albyrock87 avatar birdie0 avatar developerdizzle avatar drdla avatar jorgebucaran avatar kyleshevlin avatar motss avatar robhil avatar vladshcherbin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

classcat's Issues

Numbers as CSS classes?

From the discussion on Reddit.

Curious why you allow number type rather than returning a warning or error or just skipping it.

A class that starts with a number is not valid CSS. However, I think that restriction might be going away in future revisions of the CSS spec. Even so, a number on its own is semantically meaningless without some sort of prefix.

Remove support for nested objects.

In retrospect, I shouldn't have added a feature I didn't need at the time (YAGNI), but I wanted one feature more than classNames. I still don't need this feature and think it's unnecessary bloat, so I'd like to remove it and release a 3.0 (even though I just published 2.0 with a breaking bug fix from @developerdizzle).

EDIT: If people using this project are opposed to this change, I am okay with not removing it, otherwise let's do it! ๐Ÿ”ฅ

Running benchmarks locally requires build

$ git clone https://github.com/jorgebucaran/classcat.git
$ cd classcat/bench
$ npm i
$ node .
[...]
Error: Cannot find module '../'
[...]

Only after running npm run build and applying to following patch to bench/index.js

-const cc = require("../")
+const cc = require("../dist/classcat")

was I able to run the benchmarks as described in bench/README.md

Benchmark is kinda unfair

Hey ๐Ÿ‘‹

I've check provided string benchmark which has ['one', 'two', 'three'] argument. It produces one two three class.

Both classnames and clsx don't need to use array argument for this - clsx('one', 'two', 'three') will produce same class.

Would be nice to have this reflected in benchmark to see if it has any effect. ๐Ÿค”

Don't publish the benchmark

The ./bench dir contains a benchmarking code that is not part of the module strictly speaking so it doesn't need to be published. On the same line of argument we can skip publishing the tests as well.

Suggested solution

Add an .npmignore file to the root with this content:

bench/
tests/

That's all! ๐Ÿ‘

imported could not be resolved

// Install with npm
npm i classcat
// foo.tsx
import classcat from 'classcat'

bundle with rollup(transpile with typescript)

show warning: 'classcat' is imported by src\js\foo.tsx, but could not be resolved โ€“ treating it as an external dependency

no problem with other import

readme suggestion: unary function

Perhaps you could mention that cc is a unary function (arity of 1, accepts 1 argument) and not variadic (indefinite arity).

โ€œvariable argumentsโ€ confused me a little at first, I think using the mathematical terms is more concise, easier to google as well than linking to mdnโ€™s argument page.

Add named export or add default function name

The library currently provides only default export, which makes it a bit inconvenient for IntelliSense to provide autocomplete and automatic imports. Re-exporting with export { default as cc } from 'classcat' somewhat solves this issue, but in my opinion having named export would be beneficial as it improves developer experience.

Classes order causing issue

I'm using a utility framework with Classcat and it wasn't rendering the classes for one of the checks even thought it was evaluating to true. Switching the order of the classes, or renaming the first class made it work.

cc([
    'mr-auto px-1 py-0.5 font-bold tracking-lg rounded',
    {
        'text-black bg-white': isNew(order),
-       'text-white bg-grey': isPending(order), // don't work
+       'bg-grey text-white': isPending(order), // works
// or
+       'text-green bg-grey': isPending(order), // works
        'text-white bg-grey': isAccepted(order),
        'text-red bg-white': isExpired(order),
    }
])

I'm reporting because it looks like a bug.

Better support for CSS Modules

I initially started using classnames and discovered classcat about 3 years ago and always preferred it due to its size and speed.

However, classnames offer a very handy method called bind to make it easier to work with CSS Modules.

Do you have plans to implement something similar?

Export CommonJS module

Congratulations on the v4 release ๐ŸŽ‰

Btw, our Jest tests are broken with the classcat v4 ๐Ÿ˜ข

/home/wata727/ghq/github.com/wata727/sideci/node_modules/classcat/src/index.js:3                         
    export default function cc(names) {                                                                      
    ^^^^^^                                                                                                   

    SyntaxError: Unexpected token export

      13 |   readonly className?: string
      14 |   readonly onClick?: (children: string) => void
    > 15 |   readonly children: string
         |                                    ^
      16 |   readonly dismissible?: boolean
      17 |   readonly button?: boolean
      18 |   readonly "data-spec"?: string

      at ScriptTransformer._transformAndBuildScript (../node_modules/@jest/transform/build/ScriptTransformer.js:471:17)
      at ScriptTransformer.transform (../node_modules/@jest/transform/build/ScriptTransformer.js:513:25)
      at Object.<anonymous> (src/cheshire/components/Chip/index.tsx:15:36)

I guess that's probably because the main target is now an ES module. But Jest doesn't support ES modules natively. See jestjs/jest#4842

My team thinks it is not a good idea to introduce Babel just because of this problem... Could you also support CommonJS style modules? Thank you.

Bundling error with 3.1.1

Good morning! ๐Ÿ‘‹

As per 3.1.1 (which changed bundling system to iife), Webpack bundling of classcat causes the following error:

TypeError: classcat__WEBPACK_IMPORTED_MODULE_1___default(...) is not a function

With all due respect, I suggest not changing what your library exports in a patch. ๐Ÿ˜„

You probably should roll back to 3.1.0 or publish 3.1.2 with amd bundling and offer iife in 4.0.0 or optionally in a minor along side with the existing export interface.

Hope it helps!

BUG: Incorrect typings due to missing supported types

Description

While the function already supports the following missing types, the typings does not and this renders TypeScript to not be able to run the type check without any errors.

Proposals

  1. Use safer unknown to accept any types
    export as namespace Classcat
    
    /**
     * @param names A string, array or object of CSS class names (as keys).
     * @returns The class attribute string.
     */
    export default function (names: unknown): string
    
  2. Add missing undefined and null
    - export type Class = string | number | ClassObject | ClassArray
    + export type Class = string | number | undefined | null | ClassObject | ClassArray
    ...

Fix CodePen Example

https://codepen.io/colshacol/pen/MOzMOQ?editors=0010

I went to check out the CodePen example and found that it did not work.

screenshot 2017-11-30 09 55 38

I referred to the hyperapp docs and found that app.view needed to be composed of two functions rather than one function that takes two arguments.

Then I got a similar error with actions.toggle and found in the docs that actions should be structured the same way as the view.

I made these changes on a "fork" for you to review and update your existing CodePen example.


... And, for compliance and to make myself feel like a real contributor...

Expected:

When going to check out the CodePen example, the example works.

Actual:

When going to check out the CodePen example, the example not works.

Steps to Reproduce:

Go checkout the CodePen example.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.