Exploring ways to enhance my website, I am considering allowing users to customize the theme according to their preferences. To start off, I decided to introduce a 'Dark theme' option. In order to implement this feature effectively, I am working on integrating the dark theme separately. https://i.sstatic.net/BiWBZ.png
The screenshot above showcases a modal window where users can select the dark theme and modify the color scheme of the site. This interactive component is referred to as customize.component.html
. Meanwhile, in the backdrop, you will find the display of the website results denoted by results.component.html
.
customize.component.ts
<link type="text/javascript" href="../../assets/themes/theme.js" id="theme">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<!-- Start ignoring HTMLLintBear -->
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<!-- Stop ignoring HTMLLintBear -->
<h2 class="modal-title" id="my-modal-label">Customization</h2>
</div>
<div class="modal-body">
<button class="theme-button" id="dark" onclick="darkTheme(title)">Dark Theme</button>
</div>
</div>
</div>
results.component.ts
<!-- Customization modal-box -->
<link type="text/javascript" href="../../assets/themes/theme.js">
<div class="modal fade" id="customization" tabindex="-1" role="dialog" aria-labelledby="myModallabel">
<app-customize></app-customize>
</div>
This code snippet demonstrates both components. Additionally, I have created a file named theme.js
where the theme processing functionality is defined. However, I am encountering issues with the execution of the code.
theme.js
function darkTheme(id) {
var el = document.getElementById(id);
el.style.color = "red";
}
I am seeking guidance on how to access elements with an id from results.component.ts
. I am currently facing challenges in implementing this specific feature. Your assistance would be greatly appreciated! Thank you!
NOTE - Angular Material 2 is not being utilized in my project, hence requiring an alternative method for enabling users to customize themes without Angular Material 2.