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

Append or prepend name to file and component name. #168

Closed
johnpittman opened this issue Sep 9, 2018 · 15 comments
Closed

Append or prepend name to file and component name. #168

johnpittman opened this issue Sep 9, 2018 · 15 comments

Comments

@johnpittman
Copy link

Due to naming conflicts I would like to be able to append "Icon" to the file and component name. Having an option such as --postfixName or --prefixName that would do that would be great.

@johnpittman johnpittman changed the title Append name to output name. Append or prepend name to output name. Sep 9, 2018
@johnpittman johnpittman changed the title Append or prepend name to output name. Append or prepend name to file and component name. Sep 9, 2018
@TrySound
Copy link
Contributor

TrySound commented Sep 9, 2018

I found a better solution. I'm currently working on this feature #161

Locally I for a while generate this file. Namespace works like prefix.

import * as icons from '../../icons';

Otherwise you may generate default export like in builtin template and import it with any name you want

import PersonIcon from '../../icons/Person.js';

@johnpittman
Copy link
Author

What about the ability to export each to a folder as index.ext? I need this too so that I can generate a docz for each to be able to see what the icon looks like in my living library.

@johnpittman
Copy link
Author

This is why I need to be able to change the generated name:

"error  Shadowing of global property 'Infinity'  no-shadow-restricted-names"

@TrySound
Copy link
Contributor

TrySound commented Sep 9, 2018

I don't get tbh. Could you show an example?

@johnpittman
Copy link
Author

johnpittman commented Sep 9, 2018 via email

@TrySound
Copy link
Contributor

TrySound commented Sep 9, 2018

I dont get why this does not fit your needs?

import PersonIcon from '../../icons/Person.js';

Or which global scope you mean? Window one?

@johnpittman
Copy link
Author

johnpittman commented Sep 9, 2018 via email

@johnpittman
Copy link
Author

johnpittman commented Sep 9, 2018 via email

@TrySound
Copy link
Contributor

TrySound commented Sep 9, 2018

Export without name is bad for debugging. Which global scope do you mean? Modules are isolated from each other. Be more descriptive please. It's not clear what are you trying to achieve.

@johnpittman
Copy link
Author

johnpittman commented Sep 9, 2018 via email

@johnpittman
Copy link
Author

johnpittman commented Sep 9, 2018 via email

@TrySound
Copy link
Contributor

TrySound commented Sep 9, 2018

As a simple solution you may modify template like this

import { getProps } from './util'

export const getProps = config => {
  const props = []
  if (config.ref) props.push('svgRef')
  if (config.titleProp) props.push('title')
  if (config.expandProps) props.push('...props')

  if (props.length === 0) return '()'
  if (props.length === 1 && config.expandProps) return 'props'

  return `({ ${props.join(', ')} })`
}

const reactDomTemplate = (code, config, state) => `
import React from 'react'

// Here you simply modify icon name
// sure filename is not changed but at least your auto import feature should work
export default function ${state.componentName}Icon${getProps(config)} {
  return ${code}
}
`

@gregberge
Copy link
Owner

I understand the problem, I will think about it to find an elegant solution.

@johnpittman
Copy link
Author

johnpittman commented Sep 15, 2018 via email

@gregberge
Copy link
Owner

Follow up in #190.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants