Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

feat: component dropdown #2064

Merged
merged 3 commits into from
Jun 9, 2020
Merged

feat: component dropdown #2064

merged 3 commits into from
Jun 9, 2020

Conversation

goga-m
Copy link
Contributor

@goga-m goga-m commented Jun 9, 2020

Summary

General-purpose Dropdown component.

  • Accepts a list of options [{label: 'Option 1', value: '1'}] - Triggers onSelect event
  • or custom content <Dropdown>custom content</Dropdown>
  • Custom toggle svg icon name with toggleIcon prop
    <Dropdown iconName="settings">custom content</Dropdown>

Checklist

  • Documentation (if necessary)
  • Tests (if necessary)
  • Ready to be merged

@goga-m goga-m requested a review from faustbrian as a code owner June 9, 2020 07:29
@ghost ghost added the Complexity: High More than 256 lines changed. label Jun 9, 2020
@goga-m goga-m changed the title Feat/component dropdown feat:component dropdown Jun 9, 2020
@goga-m goga-m changed the title feat:component dropdown feat: component dropdown Jun 9, 2020
@codecov
Copy link

codecov bot commented Jun 9, 2020

Codecov Report

Merging #2064 into 3.0-react will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           3.0-react     #2064   +/-   ##
===========================================
  Coverage     100.00%   100.00%           
===========================================
  Files             33        35    +2     
  Lines            211       234   +23     
  Branches          33        37    +4     
===========================================
+ Hits             211       234   +23     
Impacted Files Coverage Δ
src/app/components/Dropdown/Dropdown.tsx 100.00% <100.00%> (ø)
src/app/components/Dropdown/hooks.ts 100.00% <100.00%> (ø)
src/app/components/Select/Select.tsx 100.00% <100.00%> (ø)
src/app/components/Textarea/Textarea.tsx 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ee8a2b0...c9833f4. Read the comment docs.

/*
* Toggle & hide dropdown content.
*/
const toggle = () => setIsOpen(!isOpen);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you think toggle and hide are not clear enough in this case and you feel like you need a comment you should maybe rename it to something like toggleContent and hideContent.

* Hide dropdown upon option click.
* Call `onSelect` and close dropdown.
*/
const select = (option: Option) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as toggle and hide. If you feel the need for a comment because the method names or code give no indication of what is happening you should rename them or make it more clear otherwise.

* Hook to hide dropdown on outside click event.
*/
const ref = useRef(null);
useEffect(() => clickOutsideHandler(ref, hide), [ref]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as toggle and hide. If you feel the need for a comment because the method names or code give no indication of what is happening you should rename them or make it more clear otherwise.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessary indeed. Removed them.

@faustbrian faustbrian merged commit 92a257c into 3.0-react Jun 9, 2020
@ghost ghost deleted the feat/component-dropdown branch June 9, 2020 07:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Complexity: High More than 256 lines changed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants