Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Commit

Permalink
[UI]: added initial ui package with a bare bones Collapse component. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
leebeydoun committed Mar 5, 2022
1 parent 46c9b69 commit 98e3c5a
Show file tree
Hide file tree
Showing 9 changed files with 181 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/fuzzy-worms-camp.md
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.
2 changes: 1 addition & 1 deletion .husky/commit-msg
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ INPUT_FILE=$1

START_LINE=`head -n1 $INPUT_FILE`

ACCEPTED_LIST="ROOT|WINDOW|VERSION"
ACCEPTED_LIST="ROOT|UI|AYA|WINDOW|VERSION"

PATTERN="^\[(${ACCEPTED_LIST})\]: [a-z0-9].+\."

Expand Down
16 changes: 16 additions & 0 deletions packages/ui/.swcrc
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"]
}
}
3 changes: 3 additions & 0 deletions packages/ui/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @resembli/ui

Work in progress
51 changes: 51 additions & 0 deletions packages/ui/package.json
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"
}
}
32 changes: 32 additions & 0 deletions packages/ui/src/components/Collapse.tsx
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>
)
}
1 change: 1 addition & 0 deletions packages/ui/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { Collapse } from "./components/Collapse"
7 changes: 7 additions & 0 deletions packages/ui/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../tsconfig.base.json",
"include": ["./src"],
"compilerOptions": {
"outDir": "dist/types"
}
}
65 changes: 65 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 98e3c5a

Please sign in to comment.