There are a few different approaches you can take:
1. Keep it basic
Sometimes, all you need is a simple template that won't interfere with the rest of the DOM. Create a very basic template that can be easily inserted anywhere without impacting styling or class names. Let your colleagues handle the rest of the template creation so that the component remains independent of your design choices.
Of course, this might be considered an extreme solution!
2. Wrap your component with logic
Instead of directly creating a button element in your template, consider wrapping the necessary logic in a div element. This way, your template can include event handlers and other functionality while still allowing your colleagues to provide the actual button through transclusion. Here's an example of a 'custom-button' component template:
<div (click)="handleClickEvent($event)">
<ng-content></ng-content>
</div>
In the parent component, you could use it like this:
<custom-button>
<button class="btn btn-primary">
<i class="fa fa-chevron-right"></i>
</button>
</custom-button>
3. Stick with classic HTML/CSS
Give your component a basic template and add class names that your colleagues can style using CSS. While this approach may make it easier for you to set up the initial component, it could potentially create issues for your colleagues when trying to apply styles due to naming conventions or nested nodes.
4. Allow entry points for custom styles
To achieve this, you'll need to use an @Input() variable.
@Input() customStyles: any;
You can then apply these styles to HTML elements using [ngStyle]:
<button [ngStyle]="customStyles">Send</div>
The customStyles variable should follow a specific format as outlined in the official documentation.
In the parent template, you can provide styles like this:
<custom-button [customStyles]="{'max-width.px': widthExp}"></custom-button>
The downside here is that you'll need to expose individual variables for styling each node in your template.
5. Allow entry point for custom class
Similar to the previous method, this approach involves accepting a class name from your colleagues via an @Input() variable.
@Input() customClass : string;
In your template, this custom class will be added to the outermost div:
<div class="someClass {{ customClass }}> <!-- Outer div -->
<!-- Child elements -->
</div>
Your colleagues can then provide a class name and style the child elements accordingly in a CSS file based on the structure you've created.
.bigButton {
height: 500px;
width: 1000px;
}
.bigButton > div {
padding: 100px;
}
.bigButton:hover > div {
// ...
}
In the parent template:
<custom-button [customClass]="'bigButton'"></custom-button>