
Research
Two Malicious Rust Crates Impersonate Popular Logger to Steal Wallet Keys
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
@asyarb/twix
Advanced tools
twix
is a small utility for constructing classnames using a variant based api.
The API is largely copied from stitches but works with
just plain class strings instead.
twix
has a peer dependency on clsx
, a small utility for conditionally
toggling class names.
npm i @asyarb/twix clsx
const button = twix({
base: 'rounded',
variants: {
color: {
purple: 'bg-purple',
blue: 'bg-blue',
},
size: {
small: 'p-5',
large: 'p-8',
},
},
compoundVariants: [
{
color: 'purple',
size: 'small',
class: 'font-bold',
},
],
defaultVariants: {
size: 'large',
},
})
// => "rounded p-8 bg-purple"
button({ color: 'purple' })
// => "rounded p-5 bg-purple font-bold"
button({ color: 'purple', size: 'small' })
twix
is written in TypeScript, and provides type-safety when defining and
using your variants.
import type { GetVariants } from '@asyarb/twix'
// ... Same button from above.
// => TypeScript error - Variants must be provided.
button()
// => TypeScript error - Must provide `color` since no defaultVariant exists.
button({ size: 'small' })
// => Get variants as a type you can re-use elsewhere:
/**
* { color: 'purple' | 'blue', size?: 'small' | 'large' }
*/
type ButtonVariants = GetVariants<typeof button>
The function returned from twix
can also append arbitrary classes if desired.
// ... Same button from above.
// => "rounded p-5 bg-purple font-bold arbitrary"
button({ color: 'purple', size: 'small', class: 'arbitrary' })
// components/Button.tsx
import { GetVariants, twix } from '@asyarb/twix'
const button = twix({
/** Same example from above... */
})
type ButtonProps = {
/** Userland props... */
} & GetVariants<typeof button>
const Button = ({ color, size, ...props }: ButtonProps) => {
return <button className={button({ color, size })} {...props} />
}
FAQs
Create variant based className strings.
We found that @asyarb/twix demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.