vrizo / uibook

Lightweight tool for React components visual testing with media queries
MIT License
228 stars 6 forks source link

Name of page in non-latin letters #5

Closed monochromer closed 4 years ago

monochromer commented 5 years ago

I get an error if the page name is typed in non-Latin letters:

page-select.js:19 Uncaught TypeError: Cannot read property 'join' of null
    at Object.optionFromPage (page-select.js:19)
    at Object.eval (page-select.js:26)
    at Array.map (<anonymous>)
    at Object.render (page-select.js:24)

Code:

const ButtonUibook = {
  name: 'Звонок',
  component: CallPreview,
  cases: [
    () => (
      <UibookCase props={{ ...PROPS }} />
    )
  ]
}
vrizo commented 5 years ago

Hi, @monochromer !

Thanks for your question! I supposed that name should be the same as the component name in the code, but I see that custom name would be a nice feature. Also, failing join without explanation seems to be bad DX, so I'll change it.

As I mentioned before, I'm on vacation right now, so it's going to take some time.

vrizo commented 4 years ago

Hi @monochromer !

Sorry for the long answer.

Uibook supports Cyrillic name now. Also I fixed coverting from CamelCase to space-separated component name.

Cyrillic name

I'm going to get rid of name key in Uibook Page at all. It must be the same as key in Uibook Controller, so it is duplicated for no reason. Hope to do it soon :)

export default UibookStarter({
  pages: {
    Plan,
    РадиоКнопочка: RadioButton, // must be the same as `name` prop in Uibook Case
    Select
  }
})
vrizo commented 4 years ago

The name key passes to Uibook Case automatically now. You can remove name from all Cases safely.

The key in Uibook Controller represents Page Name since v.0.6.0. You can use any Name in CamelCase.

{
  TheBestButton: ButtonUibook,
  Agree: CheckboxUibook,
  ВсплывающееОкно: PopupUibook
}
vrizo commented 4 years ago

Hey, @monochromer ! Have you tried the feature? :)

monochromer commented 4 years ago

Not yet. If you you want, you may close this issue.

vrizo commented 4 years ago

Closing this issue due to inactivity. It works correctly to me: https://amplifr.com/uikit/#РадиоКнопочка:ru

Thanks for submitting the bug!