<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Atomic Design Methodology &#8211; Xojo Programming Blog</title>
	<atom:link href="https://blog.xojo.com/tag/atomic-design-methodology/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.xojo.com</link>
	<description>Blog about the Xojo programming language and IDE</description>
	<lastBuildDate>Mon, 18 Aug 2025 20:41:19 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>Building a Vertical Navigation for your Web Application</title>
		<link>https://blog.xojo.com/2023/03/29/building-a-vertical-navigation-for-your-web-application/</link>
		
		<dc:creator><![CDATA[Ricardo Cruz]]></dc:creator>
		<pubDate>Wed, 29 Mar 2023 12:41:00 +0000</pubDate>
				<category><![CDATA[Learning]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Animation]]></category>
		<category><![CDATA[Atomic Design Methodology]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[webdev]]></category>
		<category><![CDATA[Xojo Code]]></category>
		<category><![CDATA[Xojo Programming Language]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=11472</guid>

					<description><![CDATA[Composing new controls using primitives is something you definitely want to explore. Let’s build a reusable vertical navigation, with animations, for your Xojo Web projects using the Atomic Design Methodology.]]></description>
										<content:encoded><![CDATA[
<p>Composing new controls using primitives is something you definitely want to explore. Let’s build a reusable vertical navigation, with animations, for your Xojo Web projects.</p>



<h2 class="wp-block-heading">Brief introduction to the Atomic Design Methodology</h2>



<p>If you haven&#8217;t heard about Atomic Design before, I really recommend that you dig a bit into this topic. With this way of methodology in mind, we will start building the smallest controls we can. Then, we will compose more complex controls reusing the smallest.</p>



<p>Keep in mind you don&#8217;t really need to blindly follow the Atoms, Molecules and Organisms proposed categories, and don&#8217;t overthink where to categorize them. As long as you can compose controls with other controls, that&#8217;s perfect. Adapt it to your own personal way of building software.</p>



<p>The idea resonates perfectly with Xojo and, while we will create a few web controls in this example, you can apply it to other targets like Desktop or Mobile.</p>



<p>Here is a <a href="https://www.youtube.com/watch?v=W-h1FtNYim4">video</a> from Brad Frost, the person behind Atomic Design Methodology.</p>



<h2 class="wp-block-heading">Containers to the rescue! </h2>



<p>In this case, we won&#8217;t need to use any Web SDK control, CSS or JavaScript. We will be using just plain Xojo Web Containers for creating our Atoms and Molecules.</p>



<p>This is how Twitter&#8217;s navigation sidebar looks like:</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img fetchpriority="high" decoding="async" width="280" height="481" src="https://blog.xojo.com/wp-content/uploads/2023/03/Explore.png" alt="" class="wp-image-11473" srcset="https://blog.xojo.com/wp-content/uploads/2023/03/Explore.png 280w, https://blog.xojo.com/wp-content/uploads/2023/03/Explore-175x300.png 175w" sizes="(max-width: 280px) 100vw, 280px" /><figcaption class="wp-element-caption">Twitter Vertical Navigation</figcaption></figure>
</div>


<p>We will create something similar. Using Atomic Design, let&#8217;s break it down it into a few new reusable controls:</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img decoding="async" width="700" height="525" src="https://blog.xojo.com/wp-content/uploads/2023/03/components-atomic-design.png" alt="" class="wp-image-11474" srcset="https://blog.xojo.com/wp-content/uploads/2023/03/components-atomic-design.png 700w, https://blog.xojo.com/wp-content/uploads/2023/03/components-atomic-design-300x225.png 300w" sizes="(max-width: 700px) 100vw, 700px" /><figcaption class="wp-element-caption">Individual Controls</figcaption></figure>
</div>


<p>Each Atom, Molecule and Organism will be a Container. In the above image, we have identified each of them.</p>



<ul class="wp-block-list">
<li>There is a &#8220;Navigation Link Icon&#8221;, an Atom, which will show one of the available <a rel="noreferrer noopener" href="https://icons.getbootstrap.com" data-type="URL" data-id="https://icons.getbootstrap.com" target="_blank">Bootstrap Icons</a>. As you notice in the Twitter example, if the link is active, the icon will be filled.</li>



<li>For the label Atom, we can just use the WebLabel built-in control. There is no need to wrap it in a Container, in this case.</li>



<li>The navigation link will be a Molecule, combining the icon and the label.</li>



<li>The Active Link Indicator will move to the active link, using an animation.</li>



<li>Finally, the Vertical Navigation Control will be the Organism, combining everything into one.</li>
</ul>



<h2 class="wp-block-heading">Navigation Link Icon</h2>



<p>This Control is basically a Container, with an ImageViewer inside. Technically, this could be just an ImageViewer subclass, but using a WebContainer we can also specify its default width and height.</p>



<p>It will have two computed properties:</p>



<ul class="wp-block-list">
<li>Active As Boolean</li>



<li>IconName As String</li>
</ul>



<p>There will also be a private ShowIcon method. Whenever you change either the Active property or IconName, the computed property will call ShowIcon.</p>



<p>The magic is inside ShowIcon:</p>



<pre class="wp-block-code Xojo"><code><code>Var iconColor As Color = If(mActive, Color.Black, Color.LightGray)
Var icon As String = If(mActive, mIconName + "-fill", mIconName)
IconImageViewer.Picture = WebPicture.BootstrapIcon(icon, iconColor)</code></code></pre>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img decoding="async" width="1024" height="716" src="https://blog.xojo.com/wp-content/uploads/2023/03/Captura-de-Pantalla-2023-03-27-a-las-13.55.04-1024x716.png" alt="" class="wp-image-11475" srcset="https://blog.xojo.com/wp-content/uploads/2023/03/Captura-de-Pantalla-2023-03-27-a-las-13.55.04-1024x716.png 1024w, https://blog.xojo.com/wp-content/uploads/2023/03/Captura-de-Pantalla-2023-03-27-a-las-13.55.04-300x210.png 300w, https://blog.xojo.com/wp-content/uploads/2023/03/Captura-de-Pantalla-2023-03-27-a-las-13.55.04-768x537.png 768w, https://blog.xojo.com/wp-content/uploads/2023/03/Captura-de-Pantalla-2023-03-27-a-las-13.55.04.png 1381w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption class="wp-element-caption">NavigationLinkIcon in the IDE</figcaption></figure>
</div>


<p>The icon color will be either LightGray or Black, depending if it&#8217;s active or not. There are also a lot of Bootstrap Icons with the &#8220;-fill&#8221; suffix so we&#8217;ll use them. This will force us to only use icons which have that suffix, but we will have to live with that.</p>



<p>The final trick is to use the Inspector Behavior and expose our Active and IconName computed properties. Right click on NavigationLinkIcon, then click on Inspector Behavior:</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="400" height="508" src="https://blog.xojo.com/wp-content/uploads/2023/03/Open-in-New-Tab.png" alt="" class="wp-image-11476" srcset="https://blog.xojo.com/wp-content/uploads/2023/03/Open-in-New-Tab.png 400w, https://blog.xojo.com/wp-content/uploads/2023/03/Open-in-New-Tab-236x300.png 236w" sizes="auto, (max-width: 400px) 100vw, 400px" /><figcaption class="wp-element-caption">How to open the Inspector Behavior</figcaption></figure>
</div>


<p>From there you can enable the checkboxes and define their default value:</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="716" src="https://blog.xojo.com/wp-content/uploads/2023/03/Captura-de-Pantalla-2023-03-27-a-las-14.00.49-1024x716.png" alt="" class="wp-image-11477" srcset="https://blog.xojo.com/wp-content/uploads/2023/03/Captura-de-Pantalla-2023-03-27-a-las-14.00.49-1024x716.png 1024w, https://blog.xojo.com/wp-content/uploads/2023/03/Captura-de-Pantalla-2023-03-27-a-las-14.00.49-300x210.png 300w, https://blog.xojo.com/wp-content/uploads/2023/03/Captura-de-Pantalla-2023-03-27-a-las-14.00.49-768x537.png 768w, https://blog.xojo.com/wp-content/uploads/2023/03/Captura-de-Pantalla-2023-03-27-a-las-14.00.49.png 1381w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /><figcaption class="wp-element-caption">Enabling properties in the Inspector Behavior</figcaption></figure>
</div>


<p>Now that we have the Control ready, let&#8217;s see how it works on its own:</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="716" src="https://blog.xojo.com/wp-content/uploads/2023/03/Captura-de-Pantalla-2023-03-27-a-las-13.51.02-1024x716.png" alt="" class="wp-image-11478" srcset="https://blog.xojo.com/wp-content/uploads/2023/03/Captura-de-Pantalla-2023-03-27-a-las-13.51.02-1024x716.png 1024w, https://blog.xojo.com/wp-content/uploads/2023/03/Captura-de-Pantalla-2023-03-27-a-las-13.51.02-300x210.png 300w, https://blog.xojo.com/wp-content/uploads/2023/03/Captura-de-Pantalla-2023-03-27-a-las-13.51.02-768x537.png 768w, https://blog.xojo.com/wp-content/uploads/2023/03/Captura-de-Pantalla-2023-03-27-a-las-13.51.02.png 1381w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /><figcaption class="wp-element-caption">NavigationLinkIcon demo</figcaption></figure>
</div>


<figure class="wp-block-video aligncenter"><video height="488" style="aspect-ratio: 660 / 488;" width="660" controls src="https://blog.xojo.com/wp-content/uploads/2023/03/NavigationLinkIcon-demo.mp4"></video><figcaption class="wp-element-caption">NavigationLinkIcon demo</figcaption></figure>



<p>Neat! You can reuse this Atom everywhere, including other projects.</p>



<h2 class="wp-block-heading">Navigation Link Control</h2>



<p>Combining our fresh NavigationLinkIcon, a built-in WebLabel and exposing an API, we&#8217;ll create our NavigationLink Molecule.</p>



<p>Create a new Container and place the items inside. Then add some computed properties:</p>



<ul class="wp-block-list">
<li>Active</li>



<li>Caption</li>



<li>IconName</li>
</ul>



<p>Whenever the property changes, just update the underlying control.</p>



<p>One trick, to make the control clickable, is to add a WebCanvas on top of the other controls. Implement its Pressed event and forward it as a new &#8220;Pressed&#8221; Event Definition.</p>



<p>If you want to show a pointer cursor when the user moves the mouse over your control, add this line of code into the container&#8217;s Opening event:</p>



<pre class="wp-block-code xojo"><code><code>Me.Style.Cursor = WebStyle.Cursors.Pointer</code></code></pre>



<p>This is how it looks like in the IDE:</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="716" src="https://blog.xojo.com/wp-content/uploads/2023/03/Captura-de-Pantalla-2023-03-27-a-las-14.28.18-1024x716.png" alt="" class="wp-image-11480" srcset="https://blog.xojo.com/wp-content/uploads/2023/03/Captura-de-Pantalla-2023-03-27-a-las-14.28.18-1024x716.png 1024w, https://blog.xojo.com/wp-content/uploads/2023/03/Captura-de-Pantalla-2023-03-27-a-las-14.28.18-300x210.png 300w, https://blog.xojo.com/wp-content/uploads/2023/03/Captura-de-Pantalla-2023-03-27-a-las-14.28.18-768x537.png 768w, https://blog.xojo.com/wp-content/uploads/2023/03/Captura-de-Pantalla-2023-03-27-a-las-14.28.18.png 1381w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /><figcaption class="wp-element-caption">NavigationLink in the IDE</figcaption></figure>
</div>


<p>Let&#8217;s quickly test it:</p>



<figure class="wp-block-video aligncenter"><video height="488" style="aspect-ratio: 660 / 488;" width="660" controls src="https://blog.xojo.com/wp-content/uploads/2023/03/NavigationLink-demo.mp4"></video><figcaption class="wp-element-caption">NavigationLink demo</figcaption></figure>



<p>We are getting there.</p>



<h2 class="wp-block-heading">Active Link Indicator</h2>



<p>We have most of the Atoms and Molecules created already. The Navigation Link Indicator is so simple and so tied to the Sidebar, that I don&#8217;t think creating an individual Atom for it is worth the effort.</p>



<p>Using a WebRectangle, with a line of two of code in its Opening event, will be enough. This is completely up to you!</p>



<h2 class="wp-block-heading">Vertical Navigation Control</h2>



<p>Now it&#8217;s time to glue the Atoms and Molecules together to make our first Organism. Create a new Container called VerticalNavigation.</p>



<p>Drop a WebRectangle on it. Set its Left and Top to 0, and implement its Opening event with these lines of code:</p>



<pre class="wp-block-code Xojo"><code><code>Me.Style.BorderThickness = 0
Me.Style.AddTransition("top", 0.2)</code></code></pre>



<p>That will remove the border that comes by default with this control. It will also tell the browser to animate the rectangle whenever we change the Top position.</p>



<p>The rectangle background color will be a light gray, but this is again up to you.</p>



<p>For the API we want to expose, add these Methods:</p>



<ul class="wp-block-list">
<li>AddLink(caption As String, icon As String, active As Boolean = False)</li>



<li>HandleLinkPressed(sender As NavigationLink)</li>



<li>SetActiveLink(index As Integer)</li>
</ul>



<p>AddLink and SetActiveLink can be left Public, HandleLinkPressed will be a Private Method.</p>



<p>AddLink code:</p>



<pre class="wp-block-code Xojo"><code><code>// We will create a new NavigationLink instance
// and set the properties we're receiving.
Var link As New NavigationLink
link.Caption = caption
link.IconName = icon

// For its pressed event, we will handle it
// internally in the HandleLinkPressed method.
AddHandler link.Pressed, WeakAddressOf HandleLinkPressed

// We will place it programatically in  the container.
Const padding = 10
Var linkTop As Integer = mLinks.Count * (link.Height + padding)
link.EmbedWithin(Self, padding, linkTop, Self.Width - padding, link.Height)

// A reference for this NavigationLink will be
// needed later, so we will store it internally.
mLinks.Add(link)

// Finally, if the item is active, we will
// handle it just like if it's been pressed
// by the user.
If active Then
  SetActiveLink(mLinks.LastIndex)
End If</code></code></pre>



<p>HandleLinkPressed code:</p>



<pre class="wp-block-code xojo"><code><code>SetActiveLink(mLinks.IndexOf(sender))
RaiseEvent Pressed(sender)</code></code></pre>



<p>And, finally, SetActiveLink:</p>



<pre class="wp-block-code xojo"><code><code>// Here we will loop through the NavigationLink
// references we have and enable or disable the
// Active property, depending on the index
// comparison.
For i As Integer = 0 To mLinks.LastIndex
  mLinks(i).Active = i = index
Next

// Move the visual active indicator to the
// NavigationLink position.
ActiveLinkIndicator.Top = mLinks(index).Top</code></code></pre>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="714" src="https://blog.xojo.com/wp-content/uploads/2023/03/Captura-de-Pantalla-2023-03-27-a-las-17.48.51-1024x714.png" alt="" class="wp-image-11482" srcset="https://blog.xojo.com/wp-content/uploads/2023/03/Captura-de-Pantalla-2023-03-27-a-las-17.48.51-1024x714.png 1024w, https://blog.xojo.com/wp-content/uploads/2023/03/Captura-de-Pantalla-2023-03-27-a-las-17.48.51-300x209.png 300w, https://blog.xojo.com/wp-content/uploads/2023/03/Captura-de-Pantalla-2023-03-27-a-las-17.48.51-768x535.png 768w, https://blog.xojo.com/wp-content/uploads/2023/03/Captura-de-Pantalla-2023-03-27-a-las-17.48.51.png 1485w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /><figcaption class="wp-element-caption">VerticalNavigation in the IDE</figcaption></figure>
</div>


<h2 class="wp-block-heading">Final Result</h2>



<p>Everything is ready, drop your VerticalNavigation somewhere in your WebPage and add a few links inside its Opening event:</p>



<pre class="wp-block-code xojo"><code><code>// Setting the third parameter to "True" will set that link as Active.
Me.AddLink("Home", "house")
Me.AddLink("Explore", "binoculars", True)
Me.AddLink("Notifications", "bell")</code></code></pre>



<p>You should see something similar to this:</p>



<figure class="wp-block-video aligncenter"><video height="488" style="aspect-ratio: 660 / 488;" width="660" controls src="https://blog.xojo.com/wp-content/uploads/2023/03/result-demo.mp4"></video><figcaption class="wp-element-caption">Final result!</figcaption></figure>



<p>Congratulations! You&#8217;ve built a vertical navigation, with nice transitions, using some Atomic Design principles.</p>



<p>Code repository: <a rel="noreferrer noopener" href="https://github.com/piradoiv/vertical-navigation-example" target="_blank">https://github.com/piradoiv/vertical-navigation-example</a><br>Download the project: <a rel="noreferrer noopener" href="https://github.com/piradoiv/vertical-navigation-example/archive/refs/heads/main.zip" target="_blank">vertical-navigation-example</a></p>



<p><em>Ricardo has always been curious about how things work. Growing up surrounded by computers</em> he became interested in <em>web technologies in the dial-up connections era. Xojo has been his secret weapon and language of preference since 2018. When he’s not online, chances are he will be scuba diving … or crocheting amigurumis. Find Ricardo on Twitter <a href="https://web.archive.org/web/20220805000833/https://www.twitter.com/piradoiv" target="_blank" rel="noreferrer noopener">@piradoiv</a>.</em></p>
]]></content:encoded>
					
		
		<enclosure url="https://blog.xojo.com/wp-content/uploads/2023/03/NavigationLinkIcon-demo.mp4" length="55146" type="video/mp4" />
<enclosure url="https://blog.xojo.com/wp-content/uploads/2023/03/NavigationLink-demo.mp4" length="210022" type="video/mp4" />
<enclosure url="https://blog.xojo.com/wp-content/uploads/2023/03/result-demo.mp4" length="90366" type="video/mp4" />

			</item>
	</channel>
</rss>
