<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: jesserules</title>
    <description>The latest articles on DEV Community by jesserules (@jesserules).</description>
    <link>https://dev.to/jesserules</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1094841%2Fa175628f-7b9c-493a-9816-7ced6065e2a3.jpeg</url>
      <title>DEV Community: jesserules</title>
      <link>https://dev.to/jesserules</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jesserules"/>
    <language>en</language>
    <item>
      <title>Implementing a Material Angular Theme Switching Component</title>
      <dc:creator>jesserules</dc:creator>
      <pubDate>Mon, 12 Jun 2023 18:00:45 +0000</pubDate>
      <link>https://dev.to/jesserules/implementing-a-material-angular-theme-switching-component-408m</link>
      <guid>https://dev.to/jesserules/implementing-a-material-angular-theme-switching-component-408m</guid>
      <description>&lt;h2&gt;
  
  
  Angular 16 Theme Switching
&lt;/h2&gt;

&lt;h2&gt;
  
  
  A quick knowledge drop on implementing theming
&lt;/h2&gt;

&lt;p&gt;Below is what the final outcome is and the end goal of this walkthrough.&lt;/p&gt;

&lt;p&gt;Since I am not trying to sling more ads than a recipe website here's the Git Repo upfront: &lt;a href="https://github.com/jesseRules/ThemePicker" rel="noopener noreferrer"&gt;Git Repo&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmedia.jessecarlbergphotography.com%2Fimages%2Fblog%2Fthemepickerexample.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmedia.jessecarlbergphotography.com%2Fimages%2Fblog%2Fthemepickerexample.gif" alt="Theme Selector"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can see on this website, my photography website, that you can switch out themes by clicking the icon at the top.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmedia.jessecarlbergphotography.com%2Fimages%2Fblog%2Fthemeswitcher.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmedia.jessecarlbergphotography.com%2Fimages%2Fblog%2Fthemeswitcher.jpg" alt="In Practice"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;First I created the app with the angular cli: ng new ThemePicker.&lt;/p&gt;

&lt;p&gt;I left the default to build it with css files instead of scss files to show how to migrate this.&lt;/p&gt;

&lt;p&gt;This is a common scenario I have ran into, where old apps are written with css files instead of using scss. So, let's fix this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmedia.jessecarlbergphotography.com%2Fimages%2Fblog%2Fcreatenewappwcss.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmedia.jessecarlbergphotography.com%2Fimages%2Fblog%2Fcreatenewappwcss.png" alt="create New with css"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To fix this flub of css instead of scss we are going to use a handy npm package Scss Migrate: &lt;a href="https://github.com/Teebo/scss-migrate" rel="noopener noreferrer"&gt;SCSS Migrate Git&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmedia.jessecarlbergphotography.com%2Fimages%2Fblog%2Finstallmigrationnpm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmedia.jessecarlbergphotography.com%2Fimages%2Fblog%2Finstallmigrationnpm.png" alt="installmigrationnpm"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once you have this installed you can run the command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ng g schematics-scss-migrate:scss-migrate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The command from above will have you select the "from" and the "to." In our case this is "CSS" to "SCSS"&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmedia.jessecarlbergphotography.com%2Fimages%2Fblog%2Fmigratestep1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmedia.jessecarlbergphotography.com%2Fimages%2Fblog%2Fmigratestep1.png" alt="migrate to scss step 1"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But make sure you run it from the parent of the /src file or it will only swap out styles.css to styles.scss.&lt;/p&gt;

&lt;p&gt;Running it from the parent of /src updates all the component modules as well.&lt;/p&gt;

&lt;p&gt;Run the script and select CSS to Scss for steps 1 &amp;amp; 2&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmedia.jessecarlbergphotography.com%2Fimages%2Fblog%2Fmigratestep2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmedia.jessecarlbergphotography.com%2Fimages%2Fblog%2Fmigratestep2.png" alt="migrate to scss step 2"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The third step will ask you for your app's name, you can find this in the angular.json file:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmedia.jessecarlbergphotography.com%2Fimages%2Fblog%2FAppname.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmedia.jessecarlbergphotography.com%2Fimages%2Fblog%2FAppname.png" alt="App Name"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's it!  We are now switched over to scss.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmedia.jessecarlbergphotography.com%2Fimages%2Fblog%2Fmigratetoscss.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmedia.jessecarlbergphotography.com%2Fimages%2Fblog%2Fmigratetoscss.png" alt="migrate to scss"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Make sure your angluar.json was updated with the scss schematics:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;            "projectType": "application",
            "schematics": {
                "@schematics/angular:application": {
                    "strict": true
                },
                "@schematics/angular:component": {
                    "style": "scss"
                }
            },
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmedia.jessecarlbergphotography.com%2Fimages%2Fblog%2Fangularjsonupdate.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmedia.jessecarlbergphotography.com%2Fimages%2Fblog%2Fangularjsonupdate.png" alt="Angular Json updated"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's get to theming!&lt;/p&gt;

&lt;p&gt;First, let's use an awesome NPM package to do this AngularMaterialCSSVars: &lt;a href="https://github.com/johannesjo/angular-material-css-vars" rel="noopener noreferrer"&gt;Git Repo&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmedia.jessecarlbergphotography.com%2Fimages%2Fblog%2Finstallcssvarsinstructions.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmedia.jessecarlbergphotography.com%2Fimages%2Fblog%2Finstallcssvarsinstructions.png" alt="Install CSS Vars Instructions"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Install the NPM Package:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i angular-material-css-vars -S
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmedia.jessecarlbergphotography.com%2Fimages%2Fblog%2Finstallcssvars.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmedia.jessecarlbergphotography.com%2Fimages%2Fblog%2Finstallcssvars.png" alt="Install CSS Vars"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Update your index file to include the background color class:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmedia.jessecarlbergphotography.com%2Fimages%2Fblog%2Findexfileupdate.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmedia.jessecarlbergphotography.com%2Fimages%2Fblog%2Findexfileupdate.png" alt="Index File Updated"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next update your App Module to use the Angular Material CSSVars:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmedia.jessecarlbergphotography.com%2Fimages%2Fblog%2Fappmoduleupdate.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmedia.jessecarlbergphotography.com%2Fimages%2Fblog%2Fappmoduleupdate.png" alt="App Module Updated"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To make an easy to use component to let the user change the theme on the front end lets build a standalone component:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmedia.jessecarlbergphotography.com%2Fimages%2Fblog%2Fcreatethemepickerstandalone.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmedia.jessecarlbergphotography.com%2Fimages%2Fblog%2Fcreatethemepickerstandalone.png" alt="Generate ThemePicker Component"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can find the code for this component &lt;a href="https://github.com/jesseRules/ThemePicker/blob/master/src/app/theme-picker/theme-picker.component.ts" rel="noopener noreferrer"&gt;Here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And we want the user to be able to set the theme and have it stay between sessions so lets create a storage service:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmedia.jessecarlbergphotography.com%2Fimages%2Fblog%2Fgeneratestorageservice.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fmedia.jessecarlbergphotography.com%2Fimages%2Fblog%2Fgeneratestorageservice.png" alt="Generate Storage Service"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can find the code for this service &lt;a href="https://raw.githubusercontent.com/jesseRules/ThemePicker/master/src/app/theme-picker/services/theme-storage.service.ts" rel="noopener noreferrer"&gt;Here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next in the styles.scss file we can add in the default scss variables:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@use "angular-material-css-vars" as mat-css-vars;
@use "@angular/material" as mat;
@import "@angular/material/theming";
@include mat-css-vars.init-material-css-vars();

@include mat-css-vars.mat-css-set-palette-defaults(
  mat.$light-blue-palette,
  "primary"
);
@include mat-css-vars.mat-css-set-palette-defaults(mat.$pink-palette, "accent");
@include mat-css-vars.mat-css-set-palette-defaults(mat.$red-palette, "warn");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then we can add in specific style classes for each theme, like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.isLightTheme .logonav {
  background-size: 65px;
  background-origin: content-box;
  background-repeat: no-repeat;
  background-image: url(https://media.jessecarlbergphotography.com/images/logo.png);
}

.isDarkTheme .logonav {
  background-size: 65px;
  background-origin: content-box;
  background-repeat: no-repeat;
  background-image: url(https://media.jessecarlbergphotography.com/images/logowhite.png);
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And that's it. Easy peasy.&lt;/p&gt;

&lt;p&gt;-J&lt;/p&gt;

</description>
      <category>angular</category>
      <category>material</category>
    </item>
    <item>
      <title>Building a Photography site in Angular</title>
      <dc:creator>jesserules</dc:creator>
      <pubDate>Mon, 12 Jun 2023 17:54:24 +0000</pubDate>
      <link>https://dev.to/jesserules/building-a-photography-site-in-angular-oel</link>
      <guid>https://dev.to/jesserules/building-a-photography-site-in-angular-oel</guid>
      <description>&lt;p&gt;I'm new here, so hopefully I'm doing this right. I've been spending my free time working on my side hustle as a photographer and decided to marry the two by building myself a new website.&lt;br&gt;
&lt;a href="https://jessecarlbergphotography.com"&gt;https://jessecarlbergphotography.com&lt;/a&gt;&lt;br&gt;
My current stack is: &lt;br&gt;
Angular 16,&lt;br&gt;
Angular Material, &lt;br&gt;
Bootstrap, &lt;br&gt;
Asp.net, &lt;br&gt;
Entity Framework,&lt;br&gt;
SQL Server and Mongo DBs, &lt;br&gt;
Image and Media CDN on Azure,&lt;br&gt;
all above hosted on Azure Cloud. &lt;br&gt;
I'm building out a user management and auth system now to share galleries and photos, etc. &lt;br&gt;
I thought I'd document some of the progress and share it as I go. Let me know if there's any specific interests I should focus on.&lt;br&gt;
My most recent addition was theming if you're interested check it out in my walkthrough here:&lt;br&gt;
&lt;a href="https://jessecarlbergphotography.com/news/648731df22607f04324d6ffa"&gt;https://jessecarlbergphotography.com/news/648731df22607f04324d6ffa&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But I'm looking for suggestions on cool features I should build out!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>angular</category>
      <category>aspdotnet</category>
      <category>azure</category>
    </item>
  </channel>
</rss>
