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

Add oneOfVariants option #1

Closed
iilei opened this issue Nov 6, 2019 · 4 comments
Closed

Add oneOfVariants option #1

iilei opened this issue Nov 6, 2019 · 4 comments
Labels
enhancement New feature or request

Comments

@iilei
Copy link

iilei commented Nov 6, 2019

Hi. Thanks for sharing your module.

I would like to use https://fonts.google.com/specimen/UnifrakturCook which is not available in regular variant. So if I add 700 to the variants I would expect it to be loaded but as i see it is explicitly omitting the font if merely a subset of the desired variants is included in the font.

How can I have for example Average Sans, Open Sans, UnifrakturCook, UnifrakturMaguntia in one combined menu?

imho it should not be needed to have a font matching every variant as specified in the variants but at least one.

like, instead of

this.options.variants.every((variant: Variant): boolean => font.variants.includes(variant))

rather the following:

font.variants.filter( variant =>  this.options.variants.includes(variant) ).length

Is that a change request you would accept or would you rather have a new property among the lines of oneOfVariants: ['700', 'regular'] ?

@samuelmeuli
Copy link
Owner

Hi @iilei! Sorry for not responding earlier, I somehow missed this issue.

If you only want to allow the user to pick from a handful of fonts, you could specify them using the families parameter.

If that doesn't work for your use case: Because this is quite a specific request, I'm thinking if, instead of adding a oneOfVariants option, it might make sense to add a filter parameter. This option could allow users to pass in a custom function that allows them to filter the font list however they want.

What do you think? :)

@samuelmeuli samuelmeuli added the enhancement New feature or request label Dec 1, 2019
@samuelmeuli samuelmeuli changed the title Thinking about enhancement: oneOfVariants Add oneOfVariants option Dec 1, 2019
@iilei
Copy link
Author

iilei commented Dec 2, 2019

I like the idea.
Does that imply these checks (starting at line 95) here are skipped then, if a filter function is passed?

Because that is what my request is about indeed - by the time of writing I was not able to state it that clearly. Also 👍 for revising the title 😊

@samuelmeuli
Copy link
Owner

Does that imply these checks (starting at line 95) here are skipped then, if a filter function is passed?

Good question, I'm not sure what's the best implementation choice here… To me, it would seem intuitive if the filter function were applied in the end, after all other options. That way, there wouldn't be any mutually exclusive options. But in that case, users would need to pass [] to the scripts and variants options to get the entire font list in the filter function… Maybe these defaults could be changed in the next major version.

If you'd like to implement this feature, please let me know :) Otherwise, I'll try to have a look at this sometime this week.

@samuelmeuli
Copy link
Owner

Added in v1.4.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants