<?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: Yamita</title>
    <description>The latest articles on DEV Community by Yamita (@yamita).</description>
    <link>https://dev.to/yamita</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%2F808873%2Fef8bc532-3303-435d-b9ec-aba3d3bbb2c4.png</url>
      <title>DEV Community: Yamita</title>
      <link>https://dev.to/yamita</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/yamita"/>
    <language>en</language>
    <item>
      <title>Can web components UI use dynamic data from our backends DB as input?</title>
      <dc:creator>Yamita</dc:creator>
      <pubDate>Fri, 04 Feb 2022 03:07:37 +0000</pubDate>
      <link>https://dev.to/yamita/can-web-components-ui-use-dynamic-data-from-our-backends-db-as-input-ldi</link>
      <guid>https://dev.to/yamita/can-web-components-ui-use-dynamic-data-from-our-backends-db-as-input-ldi</guid>
      <description>&lt;p&gt;Hi Team,&lt;/p&gt;

&lt;p&gt;I'm considering learning web components, either stencil or lit elements.&lt;/p&gt;

&lt;p&gt;A deal breaking for me is being able to create UI elements that can actually take data from our DB as an input and then morph the output of the UI element getting displayed. So if I have a Django backend with PostgreSQL and store two columns for [stockprice] &amp;amp; [timedate].&lt;/p&gt;

&lt;p&gt;Is there a web component framework that lets me write a UI widget like this (pseudo code)...&lt;/p&gt;

&lt;h1&gt;
  
  
  Example 1 UI - line chart stock widget
&lt;/h1&gt;

&lt;p&gt;CSS = rectangle(purple)&lt;/p&gt;

&lt;p&gt;var1 let [stockprice] = Y axis&lt;br&gt;
var2 let [datetime] = X axis&lt;/p&gt;

&lt;p&gt;CSS = 3 buttons (user options)&lt;br&gt;
button 1 if [datetime] &amp;gt;= 7days, delete (exclude)&lt;br&gt;
button 2 if [datetime] &amp;gt;= 30days, delete (exclude)&lt;br&gt;
button 3 if [datetime] &amp;gt;= 365days, delete (exclude)&lt;/p&gt;

&lt;p&gt;plot_line_chart(stockprice, datetiime)&lt;br&gt;
addbuttons()&lt;/p&gt;

&lt;p&gt;&lt;u&gt;Example1 output.&lt;br&gt;
&lt;/u&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pPqyJWQg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/26rkyn3nwhxccstom8tv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pPqyJWQg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/26rkyn3nwhxccstom8tv.png" alt="Image description" width="880" height="850"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This would in theory output a line chart with stock prices against a certain timeframe and allow the users to display if they want to view price in last 7, 30 or 365days depending on which option they click.&lt;/p&gt;

&lt;p&gt;In example 1, both the stock chart and button selection are ONE element part of the same custom UI as indicated by the purple rectangle.&lt;/p&gt;

&lt;p&gt;Bonus: if this works. could the button options be decoupled from the rectangular stock widget. i.e. PINK rectangle = stock widget stand alone and GREEN rectangle = button widget example 2 below. so we can e.g. place it as a bar underneath it for the user to click? They would still be loosely coupled so stock widget (pink rectangle) still relies on data choice from buttons (green rectangles). So instead of storing var2 within the stock widget. Can we say...&lt;/p&gt;

&lt;p&gt;var2 let [selected custom-ui-button-option] = X axis&lt;br&gt;
and then we have the button options as a separate UI element.&lt;/p&gt;

&lt;h1&gt;
  
  
  Example 2 UI [selected custom-ui-button-option] UI element
&lt;/h1&gt;

&lt;p&gt;CSS = 3 buttons (user options), rectangle(green).&lt;/p&gt;

&lt;p&gt;if button1, then 7days [datetime]&lt;br&gt;
elif button2, then 30days [datetime]&lt;br&gt;
else button3, then 365days [datetime]&lt;/p&gt;

&lt;p&gt;When one option is pressed by the user, the data from our DB would be stored INSIDE THE BUTTON, then gets passed to the UI stock widget, so it has data for the Y axis to generate a line chart.&lt;/p&gt;

&lt;p&gt;&lt;u&gt;Example 2 output.&lt;br&gt;
&lt;/u&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RoEWBDAs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8wsetd681yj01yj58dxi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RoEWBDAs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8wsetd681yj01yj58dxi.png" alt="Image description" width="880" height="909"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If this does NOT work in web components can I just do it in NextJS? If so I'd skip learning web components. However if both scenarios do work, why would anyone even bother with front end frameworks like react that create UI elements limited to their own framework ecosystem?&lt;/p&gt;

&lt;p&gt;Benny Powers in the posts below talks about some web component limitations but I'm too noob to understand it. Something about HTML only accepting strings so maybe for DB data to work in custom UI... The dictionary key value pair of key = stock price, value = [$stock_amount] would have to be converted to a [list of int stock values] then those int values converted to a [comma separated string] then feed it to the HTML custom UI? This is of course my assumption and welcome a better explanation or simply being told... Unfortunately web components cannot do what you are trying to achieve from them, here is why... Then I can at least forget about them and learn NextJS right away.&lt;/p&gt;

&lt;p&gt;PS: You don't have to know every answer to every question in this post to respond, we can build upon it with incremental knowledge that's shared.&lt;/p&gt;

&lt;p&gt;&lt;u&gt;Limitations of web components&lt;/u&gt;&lt;br&gt;
Limitation Tests (lit elements): &lt;a href="https://custom-elements-everywhere.com/libraries/lit/results/results.html"&gt;https://custom-elements-everywhere.com/libraries/lit/results/results.html&lt;/a&gt;&lt;br&gt;
Limitation Tests (stencil): &lt;a href="https://custom-elements-everywhere.com/libraries/stencil/results/results.html"&gt;https://custom-elements-everywhere.com/libraries/stencil/results/results.html&lt;/a&gt;&lt;br&gt;
Web Component Standards: &lt;a href="https://dev.to/bennypowers/lets-build-web-components-part-1-the-standards-3e85"&gt;https://dev.to/bennypowers/lets-build-web-components-part-1-the-standards-3e85&lt;/a&gt; &lt;br&gt;
Polyfills: &lt;a href="https://dev.to/bennypowers/lets-build-web-components-part-2-the-polyfills-dkh"&gt;https://dev.to/bennypowers/lets-build-web-components-part-2-the-polyfills-dkh&lt;/a&gt;&lt;br&gt;
Vanilla Components: &lt;a href="https://dev.to/bennypowers/lets-build-web-components-part-3-vanilla-components-4on3"&gt;https://dev.to/bennypowers/lets-build-web-components-part-3-vanilla-components-4on3&lt;/a&gt;&lt;br&gt;
Lit Elements: &lt;a href="https://dev.to/bennypowers/lets-build-web-components-part-5-litelement-906"&gt;https://dev.to/bennypowers/lets-build-web-components-part-5-litelement-906&lt;/a&gt;&lt;br&gt;
Bonus Tips: &lt;a href="https://dev.to/bennypowers/8-days-of-web-components-tips-39o5"&gt;https://dev.to/bennypowers/8-days-of-web-components-tips-39o5&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webcomponents</category>
      <category>nextjs</category>
      <category>javascript</category>
      <category>django</category>
    </item>
  </channel>
</rss>
