<?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: Dan</title>
    <description>The latest articles on DEV Community by Dan (@cubbk).</description>
    <link>https://dev.to/cubbk</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%2F54542%2F0738a85f-db54-4214-aaea-7b6bba3099fd.png</url>
      <title>DEV Community: Dan</title>
      <link>https://dev.to/cubbk</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/cubbk"/>
    <language>en</language>
    <item>
      <title>Use LLM's to convert figma components</title>
      <dc:creator>Dan</dc:creator>
      <pubDate>Fri, 03 Nov 2023 09:00:05 +0000</pubDate>
      <link>https://dev.to/cubbk/use-llms-to-convert-figma-components-51f</link>
      <guid>https://dev.to/cubbk/use-llms-to-convert-figma-components-51f</guid>
      <description>&lt;p&gt;A task I had is to convert this figma design to a react component. &lt;/p&gt;

&lt;p&gt;It's a button with 8 possible different states.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WJenJoIj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4k0p46g08de3vqawm5h8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WJenJoIj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4k0p46g08de3vqawm5h8.png" alt="Figma design" width="800" height="706"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;My patience was at 0 to write them by hand so I tried to use ai things as much as possible and see how good it works.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;I used &lt;a href="https://www.figma.com/community/plugin/747985167520967365/builder-io-ai-powered-figma-to-code-react-vue-tailwind-more"&gt;Builder.io figma plugin&lt;/a&gt; to generate the initial code. The way it works is that it uses the figma source json structure and feeds it to it's refined llm model.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Unfortunately it's not smart enough to see it all should be just one component and I had to get creative.&lt;/p&gt;

&lt;p&gt;So I generated just one state, the default one and got something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt;
      &lt;span class="nx"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text-black text-center text-base leading-[106.667%] uppercase self-stretch min-w-[56px] justify-center items-center border border-[color:var(--primary-black,#000)] px-3 py-3.5 rounded-sm border-solid&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
      &lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;handleChange&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;label&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/button&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;and then wrote this chatgpt prompt:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;here is a button in react using tailwind: 
"{code from before}" 

This button has the state: Default Active 

Make this button support all the possible states:

1. Default Inactive: border #000, text #000, background transparent
2. Default Active: border #000, text #fff, background #000
3. SoldOut Inactive: border #7B7B7B, text #7B7B7B, background transparent, text strikethrough
4. SoldOut Active: border #7B7B7B, text #000, background #7B7B7B
5. Notify Inactive: same as SoldOut Inactive but with an icon near text
6. Notify Active: same as SoldOut Active but with an icon near text
7 Low Stock Inactive: same as Default Inactive but with a circle icon near text
7 Low Stock Active: same as Default Active but with a circle icon near text

Combine all these states in ONE react component and make it so you can pass PROPS to it to activate each
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because the state variations are quite small this solution worked quite well, in more complex cases I expect that generating all the states with the figma plugin and then combining them all in chatgpt can be optimal even though more prompt work will need to be done to not let it mess it all up.&lt;/p&gt;

&lt;p&gt;Below are the prompts I used to refine what I got. Nothing special, standard chatgpt stuff&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;code&gt;make this use tailwind instead of style&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;add typescript types&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;the states "active" and "inactive" are too combined. Isolate them so you can pass active true or false as a separate prop&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;having the react code that you generated above, convert all the colors to tailwind using tailwind theme of "copy paste of tailwind.config.js"&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;using this code convert the pixels to REM using the tailwind theme in base 10&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;this all works excellently while the model is knowledgeable enough about the asked task. It fails hard once it is being asked to use a specific library that it doesn't really knows about much.&lt;/p&gt;

&lt;p&gt;One such library we had agreed to use in the team is &lt;a href="https://cva.style/docs"&gt;cva&lt;/a&gt; (replaces switch with a fancy style state machine)&lt;/p&gt;

&lt;p&gt;TODO&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Make Tailwind Intelisense Work Everywhere in Vscode</title>
      <dc:creator>Dan</dc:creator>
      <pubDate>Wed, 01 Nov 2023 16:12:11 +0000</pubDate>
      <link>https://dev.to/cubbk/make-tailwind-intelisense-work-everywhere-in-vscode-2468</link>
      <guid>https://dev.to/cubbk/make-tailwind-intelisense-work-everywhere-in-vscode-2468</guid>
      <description>&lt;p&gt;If you're using the &lt;a href="https://marketplace.visualstudio.com/items?itemName=bradlc.vscode-tailwindcss"&gt;Tailwind CSS IntelliSense&lt;/a&gt; vscode extension you might have noticed that this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;tailwindClasses&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text-15 p-6&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;will not show any tooltips.&lt;/p&gt;

&lt;p&gt;The easiest method without using something like &lt;a href="https://cva.style/docs"&gt;Class Variance Authority&lt;/a&gt; if you don't need state machines is to&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;tw&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;raw&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;tailwindClasses&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;tw&lt;/span&gt;&lt;span class="s2"&gt;`text-15 p-6`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and add to &lt;code&gt;settings.json&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"tailwindCSS.experimental.classRegex"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"tw`([^`]*)"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Very similar in how people use &lt;code&gt;gql&lt;/code&gt;&lt;/p&gt;

</description>
      <category>tailwindcss</category>
      <category>react</category>
    </item>
    <item>
      <title>Make Github Copilot Work in Wsl With Zscaler</title>
      <dc:creator>Dan</dc:creator>
      <pubDate>Sat, 02 Jul 2022 23:45:09 +0000</pubDate>
      <link>https://dev.to/cubbk/make-github-copilot-work-in-wsl-with-zscaler-3b5n</link>
      <guid>https://dev.to/cubbk/make-github-copilot-work-in-wsl-with-zscaler-3b5n</guid>
      <description>&lt;p&gt;TLDR: replace every occurence of &lt;code&gt;rejectUnauthorized: x&lt;/code&gt; to &lt;code&gt;rejectUnauthorized: false&lt;/code&gt; in &lt;code&gt;~/.vscode-server/extensions/github.copilot-xxx/dist/extension.js&lt;/code&gt; and restart vscode&lt;/p&gt;

&lt;p&gt;There is an ongoing issue with copilot in vscode in that it doesn't pick up the system chain of certificates and instead uses a &lt;a href="https://github.com/nodejs/node/issues/4175"&gt;hardcoded list&lt;/a&gt; of certificates. This causes problems with zscaler and similar man in the middle apps that causes it to fail to activate because it doesn't trust the certificate and gives the error &lt;code&gt;Extension activation failed: "unable to get local issuer certificate"&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;There are several ways to fix this proposed on the internet:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;use &lt;a href="https://github.com/ukoloff/win-ca"&gt;win-ca&lt;/a&gt; or &lt;a href="https://github.com/jfromaniello/mac-ca"&gt;mac-ca&lt;/a&gt; vscode extension to make available the additional certificates&lt;/li&gt;
&lt;li&gt;add zscaler self-signed certificate in Chrome by going to &lt;code&gt;chrome://settings/privacy&lt;/code&gt; &lt;a href="https://stackoverflow.com/a/60476625"&gt;more&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;run &lt;code&gt;code --ignore-certificate-errors&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The only way that worked for me though and unfortunately the most hacky is to change in the extension bundle &lt;code&gt;rejectUnauthorized&lt;/code&gt; to &lt;code&gt;false&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;open &lt;code&gt;~/.vscode-server/extensions/github.copilot-xxx/dist/extension.js&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;search every occurrence of &lt;code&gt;rejectUnauthorized:[a-z]&lt;/code&gt; regex find and change to &lt;code&gt;rejectUnauthorized: false&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Important!! In some cases &lt;code&gt;rejectUnauthorized&lt;/code&gt; will be as part of an destructured object. For example when having
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;rejectUnauthorized&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;s&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;change it to&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;r&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;rejectUnauthorized&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;s&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;options&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;rejectUnauthorized&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;restart vscode&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Based on &lt;a href="https://github.com/github-community/community/discussions/8866"&gt;https://github.com/github-community/community/discussions/8866&lt;/a&gt; and &lt;a href="https://stackoverflow.com/questions/36506539/how-do-i-get-visual-studio-code-to-trust-our-self-signed-proxy-certificate"&gt;https://stackoverflow.com/questions/36506539/how-do-i-get-visual-studio-code-to-trust-our-self-signed-proxy-certificate&lt;/a&gt;&lt;/p&gt;

</description>
      <category>githubcopilot</category>
      <category>zscaler</category>
      <category>wsl</category>
    </item>
  </channel>
</rss>
