This repository has been archived by the owner on Dec 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[UI]: added initial ui package with a bare bones Collapse component. (#…
…186)
- Loading branch information
1 parent
46c9b69
commit 98e3c5a
Showing
9 changed files
with
181 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@resembli/ui": patch | ||
--- | ||
|
||
Added initial UI package with a bare bones collapse component. |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"jsc": { | ||
"target": "es2021", | ||
"parser": { | ||
"syntax": "typescript", | ||
"tsx": true | ||
} | ||
}, | ||
"module": { | ||
"type": "es6", | ||
"strict": true | ||
}, | ||
"env": { | ||
"targets": ["defaults", "not IE 11", "maintained node versions"] | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# @resembli/ui | ||
|
||
Work in progress |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{ | ||
"name": "@resembli/ui", | ||
"description": "React UI components", | ||
"private": false, | ||
"author": "Lee Beydoun", | ||
"version": "0.0.0", | ||
"types": "src/index.ts", | ||
"main": "src/index.ts", | ||
"type": "module", | ||
"publishConfig": { | ||
"main": "dist/index.js", | ||
"types": "dist/types/index.d.ts" | ||
}, | ||
"keywords": [ | ||
"react", | ||
"reactjs" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/Resembli/ui.git", | ||
"directory": "packages/ui" | ||
}, | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/Resembli/ui/issues" | ||
}, | ||
"homepage": "https://www.resembli.com", | ||
"scripts": { | ||
"build": "swc ./src -d dist && tsc", | ||
"clean": "rimraf dist", | ||
"clean:build": "rimraf dist && swc ./src -d dist && tsc" | ||
}, | ||
"peerDependencies": { | ||
"@types/react": "^17.0.0", | ||
"@types/react-dom": "^17.0.0", | ||
"react": "^17.0.0", | ||
"react-dom": "^17.0.0" | ||
}, | ||
"peerDependenciesMeta": { | ||
"@types/react": { | ||
"optional": true | ||
}, | ||
"@types/react-dom": { | ||
"optional": true | ||
} | ||
}, | ||
"sideEffects": false, | ||
"dependencies": { | ||
"framer-motion": "^6.2.8" | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { AnimatePresence, motion } from "framer-motion" | ||
import * as React from "react" | ||
|
||
export interface CollapseProps { | ||
open?: boolean | ||
as?: keyof typeof motion | ||
} | ||
|
||
export function Collapse({ open, children, as = "div" }: React.PropsWithChildren<CollapseProps>) { | ||
const MotionElement = motion[as] | ||
|
||
return ( | ||
<AnimatePresence initial={false}> | ||
{open && ( | ||
<MotionElement | ||
key="content" | ||
initial="collapsed" | ||
animate="open" | ||
exit="collapsed" | ||
transition={{ duration: 0.2 }} | ||
style={{ overflow: "hidden" }} | ||
variants={{ | ||
open: { height: "auto" }, | ||
collapsed: { height: 0 }, | ||
}} | ||
> | ||
{children} | ||
</MotionElement> | ||
)} | ||
</AnimatePresence> | ||
) | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { Collapse } from "./components/Collapse" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": "../tsconfig.base.json", | ||
"include": ["./src"], | ||
"compilerOptions": { | ||
"outDir": "dist/types" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.