Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(primitive): add select component #78

Merged
merged 25 commits into from
Apr 22, 2022

Conversation

tarnas14
Copy link

@tarnas14 tarnas14 commented Apr 20, 2022

Description

  • select with floating options
  • using theme from Provider
  • allows dark background (by prop)
  • basic tests for initial render
  • fix jsdoc
  • change to invertedStyle (after feat: main layout #64 is merged)

@ #63

Motivation and Context

How Has This Been Tested?

run and tested manually
dropdownOnDarkOptionsOpen
dropdownOnDark
dropdownWithOptionsOpen
dropdown

image

@tarnas14 tarnas14 changed the title feat(primitive): add select component [WIP] feat(primitive): add select component Apr 20, 2022
@tarnas14 tarnas14 changed the title [WIP] feat(primitive): add select component feat(primitive): add select component Apr 21, 2022
@tarnas14 tarnas14 changed the title feat(primitive): add select component [wip] feat(primitive): add select component Apr 21, 2022
@tarnas14 tarnas14 marked this pull request as draft April 21, 2022 08:48
@tarnas14 tarnas14 changed the title [wip] feat(primitive): add select component feat(primitive): add select component Apr 21, 2022
@tarnas14 tarnas14 marked this pull request as ready for review April 21, 2022 09:18
Copy link

@tomaszantas tomaszantas left a comment

Choose a reason for hiding this comment

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

Looks good! I left few comments, but most of them is related to the inconsistency between Prettier and Eslint. Fyi, I'm working on VSCode with eslint and prettier plugins, so Prettier fixes my code whenever I save the file.


// when
await act(async () => {
render(<ThemeProvider theme={themes.light}><Select label="Test select label" value={options[0]} options={options} onChange={() => null} /></ThemeProvider>)

Choose a reason for hiding this comment

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

This line seems to be too long (around 160 characters long). Prettier should try to wrap this. I found that eslint won't complain on this. Maybe we should add max-len rule to eslint config (as warning)? What do you think? Prettier uses on 80 characters limit.

Copy link
Author

Choose a reason for hiding this comment

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

I connected prettier to eslint and ran lint:fix, it should be good now

}

type Option = { value: string; label: string; key: string; }
export type MyListboxProps = {

Choose a reason for hiding this comment

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

Suggested change
export type MyListboxProps = {
export type SelectProps = {

Copy link
Author

Choose a reason for hiding this comment

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

renamed

import ArrowBottom from '../../styles/Icons/ArrowBottom1'

import { Label, SelectButton, SelectorIcon, OptionsContainer, Option } from './styles'
import { MyListboxProps } from './types'

Choose a reason for hiding this comment

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

Suggested change
import { MyListboxProps } from './types'
import { SelectProps } from './types'

Copy link
Author

Choose a reason for hiding this comment

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

renamed

* @prop {string} label - label shown in option
* @prop {string} key - key to be used in react map
*/
const Select = ({ value, options, onChange, inverted, label }: MyListboxProps) => {

Choose a reason for hiding this comment

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

Suggested change
const Select = ({ value, options, onChange, inverted, label }: MyListboxProps) => {
const Select = ({ value, options, onChange, inverted, label }: SelectProps) => {

/>
</div>


Choose a reason for hiding this comment

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

Here are 2 empty lines - another inconsistency between prettier and eslint. Maybe we should add no-multiple-empty-lines rule?

Copy link
Author

Choose a reason for hiding this comment

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

I connected prettier to eslint and ran lint:fix, it should be good now

@@ -1,9 +1,16 @@
import darkTheme from './dark'
import lightTheme from './light'

const withShared = theme => ({
...theme,
borderRadius: (count = 1) => `${count * 10}px`,

Choose a reason for hiding this comment

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

Cool! Just curious: how did you pick up the base values (10px, 0.7px and 1.3px)?

Copy link
Author

Choose a reason for hiding this comment

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

pure guess
looked good, but I thought this way it will be easier to adjust them later ^^

Copy link

@tomaszantas tomaszantas left a comment

Choose a reason for hiding this comment

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

LGTM! You can switch to describe-it in the Select.test.tsx. But it's minor, and eventually can be changed later to not block this PR.

import themes from '../../styles/themes'
import Select from './'

test('renders label with select', async () => {

Choose a reason for hiding this comment

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

NIT: We used to:

describe('Component name', () => {
  it('should render X', () => {})
})

Copy link
Author

Choose a reason for hiding this comment

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

will do on next branch ,thanks

@tarnas14 tarnas14 merged commit 8417cb9 into launchpad_such_wow Apr 22, 2022
@tarnas14 tarnas14 deleted the launchpad/feature/63/select branch April 22, 2022 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants