<?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: Moenupa WANG</title>
    <description>The latest articles on DEV Community by Moenupa WANG (@moenupa).</description>
    <link>https://dev.to/moenupa</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%2F602701%2F1ad06325-1a2c-40a4-b3e3-09bfbfdfbf85.png</url>
      <title>DEV Community: Moenupa WANG</title>
      <link>https://dev.to/moenupa</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/moenupa"/>
    <language>en</language>
    <item>
      <title>Nuxt.js + Github Gist: Embedding a Gist within pages</title>
      <dc:creator>Moenupa WANG</dc:creator>
      <pubDate>Thu, 13 May 2021 13:46:28 +0000</pubDate>
      <link>https://dev.to/moenupa/nuxt-js-github-gist-embedding-a-gist-within-pages-4f24</link>
      <guid>https://dev.to/moenupa/nuxt-js-github-gist-embedding-a-gist-within-pages-4f24</guid>
      <description>&lt;h1&gt;
  
  
  Demonstration
&lt;/h1&gt;

&lt;p&gt;&lt;iframe src="https://codesandbox.io/embed/embed-github-gist-within-nuxtjs-ju6vv"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h1&gt;
  
  
  Short Version
&lt;/h1&gt;

&lt;p&gt;If you are quite experienced with nuxt.js, here is the logic:&lt;/p&gt;

&lt;p&gt;This approach get rid of &lt;code&gt;https://gist.github.com/xxxxx/xxxxx.js&lt;/code&gt; embedding method, and instead fetch the &lt;code&gt;json&lt;/code&gt; file provided by Github API, i.e. &lt;code&gt;https://api.github.com/gist/&lt;/code&gt; to present the data.&lt;/p&gt;

&lt;p&gt;The url format is &lt;code&gt;https://api.github.com/gist/&amp;lt;gist-id&amp;gt;&lt;/code&gt; in which &lt;code&gt;&amp;lt;gist-id&amp;gt;&lt;/code&gt; is the &lt;code&gt;xxxxxx&lt;/code&gt; bit of gist url &lt;code&gt;https://gist.github.com/username/xxxxxx&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This also would work for Vue.js with minor modifications.&lt;/p&gt;

&lt;p&gt;If you are interested, you can skip the implementation part and quick view the limitations and parallel approaches.&lt;/p&gt;

&lt;h1&gt;
  
  
  Long Version
&lt;/h1&gt;

&lt;p&gt;The motivation, some parallel approaches, implementation and limitations.&lt;/p&gt;

&lt;h2&gt;
  
  
  Motivation
&lt;/h2&gt;

&lt;p&gt;The reason I have come up with this approach is, the Github-provided &lt;code&gt;js&lt;/code&gt; script for embedding calls &lt;code&gt;document.write()&lt;/code&gt;, which is not suitable for Vue.js frameworks, without the aid of other modules and plugins. &lt;/p&gt;

&lt;p&gt;You may experience a warning below, once you embed it directly like &lt;code&gt;&amp;lt;script src="embedded-gist-js-url"&amp;gt;&amp;lt;/script&amp;gt;&lt;/code&gt; as in raw html:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Failed to execute 'write' on 'Document': It isn't possible to write into a document from an asynchronously-loaded external script unless it is explicitly opened.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Parallel Approaches
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Using &lt;a href="https://github.com/krux/postscribe/"&gt;postscribe&lt;/a&gt; with nuxt.js as a plugin like &lt;a href="https://stackoverflow.com/questions/65813422/nuxt-external-script-failed-to-execute-write-on-document-it-isnt-poss"&gt;top answer from Stack Overflow&lt;/a&gt; (second solution mentioned)&lt;/li&gt;
&lt;li&gt;Using &lt;a href="https://github.com/sudhanshu-15/vue-embed-gist"&gt;vue-embed-gist&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;em&gt;if you have other parallel approaches or ideas do let me now&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Sadly none of the above works @_@, at least for me. Therefore I choose this kind of dumb yet the only working approach.&lt;/p&gt;

&lt;h2&gt;
  
  
  Implementation
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Store the list of to-be-displayed gist ids in data.&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;async fetch() {}&lt;/code&gt; provided by nuxt.js to fetch the jsons from github API&lt;/li&gt;
&lt;li&gt;Display json files properly, with the most basic &lt;code&gt;v-for&lt;/code&gt; and &lt;code&gt;v-if&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Some styling&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For source code you can click &lt;a href="https://codesandbox.io/s/embed-github-gist-within-nuxtjs-ju6vv"&gt;this link&lt;/a&gt; or examine the demonstration at the very start of the post.&lt;/p&gt;

&lt;h2&gt;
  
  
  Limitations
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Hit limit&lt;/strong&gt; (for more info visit &lt;a href="https://docs.github.com/en/rest/overview/resources-in-the-rest-api#rate-limiting"&gt;documentation&lt;/a&gt;), unlike the unlimited hit &lt;code&gt;js&lt;/code&gt; provided by Github.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Heavier coding&lt;/strong&gt;, this approach involves a lot of coding of vue.js, adding 10-20 lines of code, while parallel approaches may only take 2-3 lines.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There may be other unknown limitations, hope you can point them out for me.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Thank you for reading this post.&lt;/p&gt;

&lt;p&gt;Again, if you are interested in the same topic, or have some ideas about this approach, or get stumbled by the same trouble, feel free to leave a comment.&lt;/p&gt;

</description>
      <category>github</category>
      <category>nuxt</category>
      <category>gist</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Loading Animation with pure CSS</title>
      <dc:creator>Moenupa WANG</dc:creator>
      <pubDate>Sun, 28 Mar 2021 13:34:35 +0000</pubDate>
      <link>https://dev.to/moenupa/loading-animation-with-pure-css-4laj</link>
      <guid>https://dev.to/moenupa/loading-animation-with-pure-css-4laj</guid>
      <description>&lt;p&gt;This article introduces a method to create a simple loading animation with PURE CSS, as demonstrated below (powered by codepen.io):&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/moenupa/embed/poNgvdx?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  HTML
&lt;/h2&gt;

&lt;p&gt;This implementation needs only one line of HTML code, like what's below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"loading"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Loading&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  CSS
&lt;/h2&gt;

&lt;p&gt;Then we move on to the major part, the CSS code.&lt;/p&gt;

&lt;p&gt;Because we have only one related html element, we use a &lt;code&gt;:before&lt;/code&gt; or &lt;code&gt;:after&lt;/code&gt; selector to implement the spinning circle. Setting its content, width, height, etc. to let it show up.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.loading&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;.loading&lt;/span&gt;&lt;span class="nd"&gt;:before&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;fixed&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;50%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;50%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;16rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;16rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.loading&lt;/span&gt;&lt;span class="nd"&gt;:before&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;""&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;50%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1rem&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;black&lt;/span&gt; &lt;span class="nb"&gt;transparent&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;p&gt;Then we will have two none-spinning quarter-circles, which is due to the &lt;code&gt;border-color: black transparent;&lt;/code&gt; setting top/bottom's color to black, and left/right's color to transparent.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GNA1W046--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c7s3dbyxlkju49qsizs3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GNA1W046--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c7s3dbyxlkju49qsizs3.png" alt="image"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Note that &lt;code&gt;position: fixed&lt;/code&gt; aligns the top-left corner to the 50%/50% position. so to align the center point to the center view point, we do the following modification to the css&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.loading&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="nc"&gt;.loading&lt;/span&gt;&lt;span class="nd"&gt;:before&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;-5rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.loading&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;4.7rem&lt;/span&gt; &lt;span class="m"&gt;1rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;text-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&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;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2d9Ybtl0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gdx9drrthv0h81asp83a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2d9Ybtl0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gdx9drrthv0h81asp83a.png" alt="image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then we shall define the spinning animation, using CSS &lt;code&gt;@keyframes&lt;/code&gt; to implement.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.loading&lt;/span&gt;&lt;span class="nd"&gt;:before&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;animation&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;loading&lt;/span&gt; &lt;span class="m"&gt;1.5s&lt;/span&gt; &lt;span class="n"&gt;linear&lt;/span&gt; &lt;span class="n"&gt;infinite&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;@keyframes&lt;/span&gt; &lt;span class="n"&gt;loading&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nt"&gt;from&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;rotate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0deg&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nt"&gt;to&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;rotate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;360deg&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also define the animation with keywords like &lt;code&gt;0% {...} 100% {...}&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Finally, a bit beautifying work and variable-replacement for future modification.&lt;/p&gt;

</description>
      <category>html</category>
      <category>css</category>
    </item>
  </channel>
</rss>
