This repository has been archived by the owner on Jun 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
366 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,10 @@ | ||
{ | ||
"parser": "typescript", | ||
"semi": true, | ||
"printWidth": 96, | ||
"useTabs": true, | ||
"tabWidth": 4, | ||
"singleQuote": true, | ||
"trailingComma": "es5", | ||
"jsxBracketSameLine": false | ||
} |
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,12 @@ | ||
.container { | ||
position: relative; | ||
} | ||
|
||
.containee { | ||
position: absolute; | ||
|
||
display: none; | ||
[data-open='true'] & { | ||
display: initial; | ||
} | ||
} |
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,42 @@ | ||
import React, { Component, RefObject } from 'react'; | ||
import classNames from 'classnames'; | ||
//@ts-ignore | ||
import createRef from 'react-create-ref'; | ||
|
||
import styles from '../abs-container.module.scss'; | ||
import positionStyles from './positions.module.scss'; | ||
|
||
export type Position = | ||
| 'top' | ||
| 'right' | ||
| 'bottom' | ||
| 'left' | ||
| 'cover' | ||
| 'none' | ||
| 'top-start' | ||
| 'right-start' | ||
| 'bottom-start' | ||
| 'left-start' | ||
| 'top-end' | ||
| 'right-end' | ||
| 'bottom-end' | ||
| 'left-end'; | ||
|
||
export type ContaineeProps = { position?: Position } & React.HTMLAttributes<HTMLDivElement>; | ||
|
||
export class Containee extends Component<ContaineeProps> { | ||
private ref: RefObject<HTMLDivElement> = createRef(); | ||
|
||
render() { | ||
const { className, position = 'bottom', ...rest } = this.props; | ||
const positionClass = positionStyles[position]; | ||
|
||
return ( | ||
<div | ||
ref={this.ref} | ||
className={classNames(styles.containee, positionClass, className)} | ||
{...rest} | ||
/> | ||
); | ||
} | ||
} |
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 * from './containee'; |
62 changes: 62 additions & 0 deletions
62
src/surfaces/abs-container/containee/positions.module.scss
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,62 @@ | ||
.top { | ||
bottom: 100%; | ||
|
||
&-start { | ||
bottom: 100%; | ||
left: 0%; | ||
} | ||
|
||
&-end { | ||
bottom: 100%; | ||
right: 0%; | ||
} | ||
} | ||
|
||
.right { | ||
left: 100%; | ||
|
||
&-start { | ||
left: 100%; | ||
top: 0%; | ||
} | ||
|
||
&-end { | ||
left: 100%; | ||
bottom: 0%; | ||
} | ||
} | ||
|
||
.bottom { | ||
top: 100%; | ||
|
||
&-start { | ||
top: 100%; | ||
left: 0%; | ||
} | ||
|
||
&-end { | ||
top: 100%; | ||
right: 0%; | ||
} | ||
} | ||
|
||
.left { | ||
right: 100%; | ||
|
||
&-start { | ||
right: 100%; | ||
top: 0%; | ||
} | ||
|
||
&-end { | ||
right: 100%; | ||
bottom: 0%; | ||
} | ||
} | ||
|
||
.cover { | ||
top: 0%; | ||
left: 0%; | ||
} | ||
|
||
// .none {} |
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,11 @@ | ||
import React from 'react'; | ||
import cn from 'classnames'; | ||
import styles from '../abs-container.module.scss'; | ||
|
||
export type ContainerProps = { open?: boolean } & React.HTMLAttributes<HTMLDivElement>; | ||
|
||
export function Container(props: ContainerProps) { | ||
const { className, open, ...rest } = props; | ||
|
||
return <div className={cn(styles.container, className)} data-open={open} {...rest} />; | ||
} |
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 * from './container'; |
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 @@ | ||
import styles from './abs-container.module.scss'; | ||
|
||
export * from './containee'; | ||
export * from './container'; | ||
|
||
export const containerClass = styles.container; | ||
export const containeeClass = styles.containee; |
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,35 @@ | ||
import React, { Component, ReactNode } from 'react'; | ||
import onClickOutside, { | ||
OnClickOutProps, | ||
InjectedOnClickOutProps, | ||
} from 'react-onclickoutside'; | ||
|
||
type Props = { | ||
children: ReactNode; | ||
disable?: boolean; | ||
onClick: (e: React.MouseEvent<HTMLElement, MouseEvent>) => void; | ||
} & InjectedOnClickOutProps; | ||
|
||
class MyComponent extends Component<Props> implements OnClickOutProps<any> { | ||
componentDidUpdate(prevProps: Props) { | ||
const nextProps = this.props; | ||
|
||
if (prevProps.disable !== nextProps.disable) { | ||
if (nextProps.disable) { | ||
this.props.disableOnClickOutside(); | ||
} else { | ||
this.props.enableOnClickOutside(); | ||
} | ||
} | ||
} | ||
|
||
handleClickOutside = (evt: React.MouseEvent<HTMLElement, MouseEvent>) => { | ||
this.props.onClick(evt); | ||
}; | ||
|
||
render() { | ||
return this.props.children; | ||
} | ||
} | ||
|
||
export const ClickOutside = onClickOutside(MyComponent); |
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 * from './click-outside'; |
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,11 @@ | ||
import React from 'react'; | ||
import classNames from 'classnames'; | ||
import styles from './drawer.module.scss'; | ||
|
||
export type DrawerPlaceholderProps = React.HTMLAttributes<HTMLDivElement>; | ||
|
||
export function DefaultPlaceholder(props: DrawerPlaceholderProps) { | ||
return ( | ||
<div {...props} className={classNames(props.className, styles.placeholder)}/> | ||
); | ||
} |
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,4 @@ | ||
.placeholder { | ||
cursor: pointer; | ||
user-select: none; | ||
} |
Oops, something went wrong.