X Tutup
The Wayback Machine - https://web.archive.org/web/20221130091654/https://github.com/angular/angular/issues/47607
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 style & styleUrl to component definition #47607

Open
yjaaidi opened this issue Oct 3, 2022 · 5 comments
Open

Add style & styleUrl to component definition #47607

yjaaidi opened this issue Oct 3, 2022 · 5 comments
Labels
area: core Issues related to the framework runtime core: stylesheets feature: votes required Feature request which is currently still in the voting phase feature Issue that requests a new feature
Milestone

Comments

@yjaaidi
Copy link
Contributor

yjaaidi commented Oct 3, 2022

Which @angular/* package(s) are relevant/related to the feature request?

core

Description

Most components are setting styles or styleUrls to an array with a single value.

@Component({
  style: `:host { ... }`
})
class MyCmp {
}

P.S.: I hope that this isn't a duplicate. It feels like something that was discussed multiple times but I couldn't find the issue.
Sorry if I missed it.

Proposed solution

It would be a nice syntactic sugar to allow style & styleUrl shortcuts.

I'd be happy to help with a PR.

@pkozlowski-opensource pkozlowski-opensource added area: core Issues related to the framework runtime core: stylesheets labels Oct 3, 2022
@ngbot ngbot bot modified the milestone: needsTriage Oct 3, 2022
@pkozlowski-opensource pkozlowski-opensource added the feature Issue that requests a new feature label Oct 3, 2022
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Oct 3, 2022
@angular-robot angular-robot bot added the feature: votes required Feature request which is currently still in the voting phase label Oct 3, 2022
@angular-robot
Copy link
Contributor

angular-robot bot commented Oct 3, 2022

This feature request is now candidate for our backlog! In the next phase, the community has 60 days to upvote. If the request receives more than 20 upvotes, we'll move it to our consideration list.

You can find more details about the feature request process in our documentation.

@JoostK
Copy link
Member

JoostK commented Oct 3, 2022

We've just discussed this and our feeling is that we'd rather avoid having multiple ways of achieving the same thing, so introducing two new component metadata properties as alternative to the existing ones—but with fewer capabilities—feels undesirable to the team.

That said, it might make sense to allow styles in particular (not styleUrls) to be string | string[], as it's still meaningful to have multiple styles in a single template string (thus there wouldn't be a need for the property to become singular).

@antischematic
Copy link

antischematic commented Oct 3, 2022

Allowing styles to be a string instead of a string array would make single file components prettier. prettier/prettier#8214

@yjaaidi
Copy link
Contributor Author

yjaaidi commented Oct 4, 2022

styles: string | string[] is a nice alternative. Though, I wonder how many tools this would break as all of them assume that styles is an array.

@angular-robot
Copy link
Contributor

angular-robot bot commented Nov 12, 2022

Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.

Find more details about Angular's feature request process in our documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: core Issues related to the framework runtime core: stylesheets feature: votes required Feature request which is currently still in the voting phase feature Issue that requests a new feature
Projects
None yet
Development

No branches or pull requests

4 participants
X Tutup