Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save airandopal/427f9022bbf4327bae13d4e1b53916c8 to your computer and use it in GitHub Desktop.

Select an option

Save airandopal/427f9022bbf4327bae13d4e1b53916c8 to your computer and use it in GitHub Desktop.

Revisions

  1. @addisonschultz addisonschultz revised this gist Jan 6, 2020. No changes.
  2. @addisonschultz addisonschultz revised this gist Jan 2, 2020. No changes.
  3. @addisonschultz addisonschultz created this gist Jan 2, 2020.
    23 changes: 23 additions & 0 deletions generatePropertyControls.ts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    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;
    }