Skip to content

Instantly share code, notes, and snippets.

View addisonschultz's full-sized avatar

Addison addisonschultz

View GitHub Profile
@addisonschultz
addisonschultz / useScript.tsx
Last active October 28, 2023 10:02
A React hook that lets you add script tags to a component. Useful when needing to load scripts for components in Framer X.
import * as React from "react"
import { useState, useEffect } from "react"
// Hook
let cachedScripts = []
export function useScript(src) {
// Keeping track of script loaded and error state
const [state, setState] = useState({
loaded: false,
@addisonschultz
addisonschultz / Component.tsx
Created July 25, 2019 07:16
A template for Code Components in Framer X
import * as React from "react";
import { Frame, addPropertyControls, ControlType } from "framer";
/**
* This import will allow Overrides made in another file available to use in our component
*
* Change the override names and file name if yours is different
*/
// import { Primary, Secondary, Destructive } from "./Examples";
@addisonschultz
addisonschultz / AddScript.js
Created August 14, 2019 10:30
Add this file into a Framer X project to load a script to the top of your project
function Loader() {
if (document.getElementById("customScript")) {
console.log("Script is already loaded!");
return;
}
const script = document.createElement("script");
script.src = "path/to/sript.js";
script.id = "customScript";
document.head.appendChild(script);
@addisonschultz
addisonschultz / addStyles.js
Last active February 18, 2021 16:31
A quick utility file to add CSS to a Framer Project
function Add() {
let css = document.createElement("link");
css.href = "path/to/styles.css";
css.id = "framerCustomCSS";
document.head.appendChild(css);
}
if (
document.getElementById("framerCustomCSS")
) {
@addisonschultz
addisonschultz / generatePropertyControls.ts
Last active July 15, 2023 23:17
Reuse Property Controls easily in Framer X
import { ControlType, PropertyControls } from "framer";
export function generatePropertyControls(
options: {
hidden?: (props: any) => boolean;
omittedProperties?: string[];
} = {}
): PropertyControls {
const properties: PropertyControls = {
// Property Controls go here
@addisonschultz
addisonschultz / slideControls.tsx
Created February 18, 2020 10:05
An Override file that lets you control the Page component as a Slides component with arrow keys in Framer
import { Override, Data } from "framer"
import * as React from "react"
const slideData = Data({ currentSlide: 0 })
export function SlideControls(props): Override {
// This sets the slidesNumber dynamically from the Page component
const slidesNumber = React.Children.toArray(props.children)[0].props
.children.length
@addisonschultz
addisonschultz / children.tsx
Created February 28, 2020 14:32
Children property controls in Framer
children: {
type: ControlType.Array,
propertyControl: {
type: ControlType.ComponentInstance,
},
},
@addisonschultz
addisonschultz / reactchildren.tsx
Last active September 14, 2023 01:15
Cloning React Children
import * as React from "react";
import { Frame, addPropertyControls, ControlType } from "framer";
export function Component({ childComponent }) {
return (
<div style={{ width: "100%" }}>
{React.Children.map(childComponent, (child, index) => {
return React.cloneElement(child, {
width: "100%",
key: index,
@addisonschultz
addisonschultz / syncly.js
Created September 3, 2024 12:49
An example of Syncly's Node.js SDK
// Import the Syncly SDK
const Syncly = require('syncly');
// Initialize Syncly client with authentication (example)
const client = new Syncly.Client({
apiKey: 'your-api-key-here'
});
// Function to create a new calendar and event
async function createCalendarAndEvent(calendarName, eventTitle, eventStart, eventEnd) {