This repository has been archived by the owner on Sep 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1183 from IFRCGo/release/v4.3.0
Release/v4.3.0
- Loading branch information
Showing
65 changed files
with
4,054 additions
and
605 deletions.
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
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,25 @@ | ||
import React from 'react'; | ||
import Portal from './portal'; | ||
import _cs from 'classnames'; | ||
|
||
function Backdrop (props) { | ||
React.useEffect(() => { | ||
const html = document.getElementsByTagName('html')[0]; | ||
const prevValue = html.style.overflow; | ||
html.style.overflow = 'hidden'; | ||
|
||
return () => { | ||
html.style.overflow = prevValue; | ||
}; | ||
}); | ||
|
||
return ( | ||
<Portal> | ||
<div className={_cs(props.className, 'tc-backdrop')}> | ||
{ props.children } | ||
</div> | ||
</Portal> | ||
); | ||
} | ||
|
||
export default Backdrop; |
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,93 @@ | ||
import React from 'react'; | ||
import { _cs } from '@togglecorp/fujs'; | ||
|
||
import { | ||
useBlurEffect, | ||
useFloatPlacement, | ||
} from '../hooks'; | ||
|
||
import Portal from './portal'; | ||
|
||
// import styles from './styles.css'; | ||
|
||
/* | ||
interface DropdownProps { | ||
className?: string; | ||
parentRef: React.RefObject<HTMLElement>; | ||
elementRef: React.RefObject<HTMLDivElement>; | ||
children: React.ReactNode; | ||
} | ||
*/ | ||
|
||
function Dropdown (props) { | ||
const { | ||
parentRef, | ||
elementRef, | ||
children, | ||
className, | ||
} = props; | ||
|
||
const placement = useFloatPlacement(parentRef); | ||
|
||
return ( | ||
<div | ||
ref={elementRef} | ||
style={placement} | ||
className={_cs('tc-dropdown-container', className)} | ||
> | ||
{ children } | ||
</div> | ||
); | ||
} | ||
|
||
/* | ||
interface Props { | ||
className?: string; | ||
dropdownContainerClassName?: string; | ||
children: React.ReactNode; | ||
label: string | undefined; | ||
} | ||
*/ | ||
|
||
function DropdownMenu (props) { | ||
const { | ||
className, | ||
dropdownContainerClassName, | ||
children, | ||
label, | ||
} = props; | ||
|
||
const buttonRef = React.useRef(null); | ||
const dropdownRef = React.useRef(null); | ||
const [showDropdown, setShowDropdown] = React.useState(false); | ||
const handleMenuClick = React.useCallback(() => { | ||
setShowDropdown(true); | ||
}, [setShowDropdown]); | ||
|
||
useBlurEffect(showDropdown, setShowDropdown, dropdownRef, buttonRef); | ||
|
||
return ( | ||
<React.Fragment> | ||
<button | ||
className={_cs(className, 'tc-dropdown-menu')} | ||
ref={buttonRef} | ||
onClick={handleMenuClick} | ||
> | ||
{ label } | ||
</button> | ||
{ showDropdown && ( | ||
<Portal> | ||
<Dropdown | ||
elementRef={dropdownRef} | ||
className={dropdownContainerClassName} | ||
parentRef={buttonRef} | ||
> | ||
{ children } | ||
</Dropdown> | ||
</Portal> | ||
)} | ||
</React.Fragment> | ||
); | ||
} | ||
|
||
export default DropdownMenu; |
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
45 changes: 45 additions & 0 deletions
45
app/assets/scripts/components/form-elements/faram-checkbox.js
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,45 @@ | ||
import React from 'react'; | ||
import { randomString } from '@togglecorp/fujs'; | ||
import { FaramInputElement } from '@togglecorp/faram'; | ||
|
||
class FaramCheckbox extends React.PureComponent { | ||
inputId = randomString(8); | ||
|
||
handleChange = (e) => { | ||
const { | ||
onChange, | ||
value, | ||
} = this.props; | ||
|
||
if (onChange) { | ||
onChange(!value); | ||
} | ||
} | ||
|
||
render () { | ||
const { | ||
value, | ||
label, | ||
} = this.props; | ||
|
||
return ( | ||
<label | ||
htmlFor={this.inputId} | ||
className='tc-faram-checkbox' | ||
> | ||
<input | ||
id={this.inputId} | ||
className='tc-faram-checkbox-input' | ||
type="checkbox" | ||
onChange={this.handleChange} | ||
checked={value} | ||
/> | ||
<div className='tc-faram-checkbox-label'> | ||
{ label } | ||
</div> | ||
</label> | ||
); | ||
} | ||
} | ||
|
||
export default FaramInputElement(FaramCheckbox); |
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
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
Oops, something went wrong.