Last active
July 15, 2023 23:17
-
-
Save addisonschultz/23df9e22cc6857383f1e830f52c16645 to your computer and use it in GitHub Desktop.
Reuse Property Controls easily in Framer X
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ControlType, PropertyControls } from "framer"; | |
export function generatePropertyControls( | |
options: { | |
hidden?: (props: any) => boolean; | |
omittedProperties?: string[]; | |
} = {} | |
): PropertyControls { | |
const properties: PropertyControls = { | |
// Property Controls go here | |
}; | |
if (!!options.omittedProperties) { | |
return Object.keys(properties).reduce<PropertyControls>((acc, key) => { | |
if (options.omittedProperties.indexOf(key) === -1) { | |
acc[key] = properties[key]; | |
} | |
return acc; | |
}, {}); | |
} | |
return properties; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage in a component: