radix-ui / icons

A crisp set of 15×15 icons designed by the @workos team.
https://radix-ui.com/icons
MIT License
2.12k stars 104 forks source link

feat: adds Framer component #162

Closed clearlysid closed 5 months ago

clearlysid commented 11 months ago

👋 Hello, thanks for the lovely icons!

I was using them in a project and needed an easy way to use them within Framer. Ended up writing a small HOC that can be pasted into Framer, allows changing the dimensions, picking a colour and selecting any icon from the list.

Made this quick PR to add it under the "Assets" section of the website, in case it might come in handy for others. Adding a small GIF to show how it works.

radix-framer


PR checklist:

(No changes that would affect the below)

vercel[bot] commented 11 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
radix-icons ❌ Failed (Inspect) Aug 7, 2023 3:02pm
clearlysid commented 11 months ago

The HOC is extremely simple, here's the code one can use in Framer to get this component in their project directly:

import * as Radix from "@radix-ui/react-icons"
import { addPropertyControls, ControlType } from "framer"

let iconsList = Object.keys(Radix)

/*
 * @framerSupportedLayoutWidth any-prefer-fixed
 * @framerSupportedLayoutHeight any-prefer-fixed
 * @framerIntrinsicHeight 24
 * @framerIntrinsicWidth 24
 */
export default function RadixIcon(props) {
    const IconComponent = Radix[props.icon]
    return <IconComponent style={{ ...props.style, color: props.color }} />
}

addPropertyControls(RadixIcon, {
    icon: {
        type: ControlType.Enum,
        defaultValue: "FramerLogoIcon",
        displaySegmentedControl: false,
        options: iconsList,
    },
    color: {
        type: ControlType.Color,
        defaultValue: "#FF007C",
    },
})