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

Projects render un-expectedly when they are exported, because of the custom tag wrapper around them #557

Closed
JayaKrishnaNamburu opened this issue Apr 20, 2021 · 1 comment
Labels
angular generators bug Something isn't working

Comments

@JayaKrishnaNamburu
Copy link
Member

Issue

When we use components in angular. We are fairly similar with the selector syntax like app-component or app-home etc. Which are similar to how custom-elements are defined. So, browsers don't have a clue on how to render these. And so defines them as inline elements.

If an element is inline the width and height doesn't effect. And so, if the element is styled internally with a width and height the changes still doesn't have any effect. Let's take a look at an example from Angular

Codesandbox link --> https://codesandbox.io/s/bjkpo
Screenshot 2021-04-20 at 8 08 56 PM

The component root has a width of 100% explicitly set by the user, but this doesn't reflect because. The encapsulated app-component behaves as a inline element.

CSS for the root element inside component

.container {
  width: 100%;
  height: 400px;
  display: flex;
  position: relative;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  background-color: var(--dl-color-success-300);
}

Let's check the same example using React
Codesandbox link --> https://codesandbox.io/s/7x28c
Screenshot 2021-04-20 at 8 08 48 PM

Solution

Screenshot 2021-04-20 at 8 27 16 PM

  • The other way is to add width to the the :host when any width is explicitly mentioned on the root of the element.
:host {
  display: block;
  width: 100%
}

My opinion is contents works the best. Since, with the second solution we might sometimes come across un-expected behaviours too.

@JayaKrishnaNamburu JayaKrishnaNamburu added bug Something isn't working angular generators labels Apr 20, 2021
@JayaKrishnaNamburu JayaKrishnaNamburu changed the title Angular Projects render un-expectedly when they are exported Angular Projects render un-expectedly when they are exported, because of the custom tag wrapper around them Apr 21, 2021
@JayaKrishnaNamburu JayaKrishnaNamburu changed the title Angular Projects render un-expectedly when they are exported, because of the custom tag wrapper around them Projects render un-expectedly when they are exported, because of the custom tag wrapper around them Apr 21, 2021
Utwo pushed a commit that referenced this issue Apr 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
angular generators bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant