<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Islam Abdalla on Medium]]></title>
        <description><![CDATA[Stories by Islam Abdalla on Medium]]></description>
        <link>https://medium.com/@sudani93?source=rss-ae48c382d20c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*La-SgDCbJiZXpqVN.</url>
            <title>Stories by Islam Abdalla on Medium</title>
            <link>https://medium.com/@sudani93?source=rss-ae48c382d20c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 02:06:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sudani93/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Named and hashed styles]]></title>
            <link>https://medium.com/the-kotlin-chronicle/named-and-hashed-styles-d201071178e1?source=rss-ae48c382d20c------2</link>
            <guid isPermaLink="false">https://medium.com/p/d201071178e1</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[kunafa]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[css]]></category>
            <dc:creator><![CDATA[Islam Abdalla]]></dc:creator>
            <pubDate>Wed, 02 Oct 2019 14:03:41 GMT</pubDate>
            <atom:updated>2019-10-02T14:03:41.411Z</atom:updated>
            <content:encoded><![CDATA[<p>Kuanfa provides an easy and convenient way for developers to write styles next to the element. It makes it easier to mentally map how the view will look and what style applies to what element. Ever tried to edit a CSS file with more than hundred thousands lines? Yeah! it sucks. However, not like writing styles inside HTML elements directly, Kunafa under the hood extracts the style { } blocks into a CSS class.</p><h3>So what’s the problem?</h3><p>Well, everything works well and beautiful, except for one thing! Whenever style { } is called, a new style will be created. That means if you have something like this:</p><pre>postsList.forEach {<br>                horizontalLayout { <br>                    style { <br>                        ...<br>                    }<br>                }<br>            }</pre><p>Then for every post in postsList a new style will be created! If you are not careful, very soon you will find that thousands of classes are created that are no longer used and will only slow down your page.</p><p>Introducing..</p><h3>Named styles</h3><p>Named styles are an easy way to reuse styles. This way, styles created can be assigned a name like this.</p><pre>postsList.forEach {<br>                horizontalLayout { <br>                    style(&quot;postRoot&quot;) { <br>                        ...<br>                    }<br>                }<br>            }</pre><p>The style is then saved with this name. Whenever the function style(“postRoot”) { } is called aftwerwards, the stored style is returned instead of creating a new one. Keep in mind that the stored style is returned regardless of the body of the second call to style(“postRoot”){} . This works perfectly for the loop case above, however it can lead to annoying bugs when the name is reused to completely different style bodies, as only the first call to the function will be saved, and subsequent call bodies will be ignored.</p><h3>Hashed styles</h3><p>Hashed styles are a special case of named styles, where instead of passing string as a name for the style, a hash for the style rule is calculated and saved as a name for the style. This has many benefits:</p><ul><li>The process is done automatically. In fact, starting from Kunafa 0.2.1, the function style {} by default is hashed.</li><li>The order of the rules withing the style function is not important.</li></ul><p>This is very useful and dramatically reduces the number of styles in the app. In face it can be more efficient than writing CSS by hand as all exactly similar styles, only one will be created and cached.</p><p>In special cases, this behavior might not be desirable. In this case, you can instruct the style function to hash and cache rule set (or use a cached rule set) as follows.</p><pre>postsList.forEach {<br>                horizontalLayout { <br>                    style(shouldHash = false) { <br>                        ...<br>                    }<br>                }<br>            }</pre><h3>Conclusion</h3><p>Hashed styles can increase the performance of the web app without the need to separate the styles from the components they are applied to. It keeps everything concise without sacrificing the developer experience. Give it a try and let us know what you think.</p><p>Happy development. Also, don’t forget to <a href="https://join.slack.com/t/kunafa/shared_invite/enQtNTczNjM2NDcwMjU4LWFiY2VkOTI5MTMxNjQ4OTcyNTBjZmNmYmQxZThhMjg4NWI2NWZkNDg2MTNjNTYyODUwZjczZmUyMmQ2MjJjMGM">us at Slack here</a>, and <a href="https://github.com/Kabbura/Kunafa">leave us a star in Github</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d201071178e1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-kotlin-chronicle/named-and-hashed-styles-d201071178e1">Named and hashed styles</a> was originally published in <a href="https://medium.com/the-kotlin-chronicle">The Kotlin Chronicle</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kunafa v0.2.0-beta.1 released]]></title>
            <link>https://medium.com/the-kotlin-chronicle/kunafa-v0-2-0-beta-1-released-d292c2e66f2d?source=rss-ae48c382d20c------2</link>
            <guid isPermaLink="false">https://medium.com/p/d292c2e66f2d</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Islam Abdalla]]></dc:creator>
            <pubDate>Thu, 04 Apr 2019 01:53:53 GMT</pubDate>
            <atom:updated>2019-04-04T01:53:53.441Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://github.com/Kabbura/Kunafa">Kunafa</a> is an easy to use, high level framework in Kotlin for front-end web-development. It allows developers to create web apps without using HTML, CSS, or JavaScript.</p><p>Kunafa v0.2.0-beta.1 has been released. To use it in a Kotlin JS project, simply add the following line to the build.gradle file</p><pre>compile &#39;com.narbase:kunafa:0.2.0-beta.1&#39;</pre><p>This release includes the following changes:</p><h4>Added new lifecycle stage `onViewCreated`</h4><p>A new lifecycle stage has been added to the view. This stage is called once when the view is first created. Currently, these are the lifecycle events of a view:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/39ed5ae98dd4ed71049cea1164ea2315/href">https://medium.com/media/39ed5ae98dd4ed71049cea1164ea2315/href</a></iframe><p>If you are using MVVM with Kunafa, `onViewCreated` is the recomemnded stage to set up the observers.</p><h4>Function `addChild` renamed to `mount`</h4><p>In view, function `addChild` has been renamed to `mount`. Now it is more obvious that when this function is called, the functions `viewWillMount` and `onViewMounted` of the child view will be called.</p><h4>Other bug fixes</h4><p>Small bug has been fixed in this release.</p><h4>Conclusion</h4><p>That’s all for this release. If you haven’t tried Kunafa yet, follow this <a href="https://github.com/Kabbura/Kunafa/wiki/Hello-Kunafa">Getting started guide</a>. <br>We would really like to hear from you. Give it a try and let us know what you think. Also, don’t forget to <a href="https://github.com/Kabbura/Kunafa">join us at Slack here</a>, and <a href="https://github.com/Kabbura/Kunafa">leave us a star in Github</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d292c2e66f2d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-kotlin-chronicle/kunafa-v0-2-0-beta-1-released-d292c2e66f2d">Kunafa v0.2.0-beta.1 released</a> was originally published in <a href="https://medium.com/the-kotlin-chronicle">The Kotlin Chronicle</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kunafa: Easy to use, high level framework in Kotlin for front-end web-development]]></title>
            <link>https://medium.com/the-kotlin-chronicle/kunafa-easy-to-use-high-level-framework-in-kotlin-for-front-end-web-development-ee5237aea5b?source=rss-ae48c382d20c------2</link>
            <guid isPermaLink="false">https://medium.com/p/ee5237aea5b</guid>
            <category><![CDATA[css]]></category>
            <category><![CDATA[html]]></category>
            <category><![CDATA[kunafa]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Islam Abdalla]]></dc:creator>
            <pubDate>Fri, 15 Mar 2019 12:07:12 GMT</pubDate>
            <atom:updated>2019-03-29T19:12:12.314Z</atom:updated>
            <content:encoded><![CDATA[<p>Here at Narbase we use Kunafa for all of our front-end web development. Since its first release in February 2018, Kunafa has evolved to become very flexible and extremely fun to use. And now, Kunafa 0.2.x has finally been released. There are many changes to the the 0.1.x releases. Here are the main changes. But before we go into details, you can join us at Slack by <a href="https://join.slack.com/t/kunafa/shared_invite/enQtNTczNjM2NDcwMjU4LWFiY2VkOTI5MTMxNjQ4OTcyNTBjZmNmYmQxZThhMjg4NWI2NWZkNDg2MTNjNTYyODUwZjczZmUyMmQ2MjJjMGM">clicking this link</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/1*8FRAPwDzVRufV6O-xvsWPw.jpeg" /></figure><h3>Styles</h3><p>Kunafa 0.2.0 has revamped the styles and styles sheets. As the philosophy of Kunafa is to make web development easy, and allow developers to do everything with Kotlin, kunafa now allows you to use almost all of CSS directly in Kotlin. <br>First, you can add a style to any view simply by balling the `style { }` function. For example:</p><pre>textView {<br>              text = &quot;Failed to connect to the internet&quot;<br>              style {<br>                  width = 290.px<br>                  height = wrapContent<br>                  textAlign = TextAlign.Center<br>                  backgroundColor = Color.white<br>                  borderRadius = 4.px.toString()<br>                  border = &quot;1px solid #d4d4d4&quot;<br>              }<br>          }</pre><p>The `style { }` function creates on-the-fly a new CSS class rule set and adds it to the `textView` view above. To reuse the same style for multiple views, you can use the following syntax.</p><pre>val errorStyle = classRuleSet {<br>      width = 290.px<br>      height = wrapContent<br>      textAlign = TextAlign.Center<br>      backgroundColor = Color.white<br>      borderRadius = 4.px.toString()<br>      border = &quot;1px solid #d4d4d4&quot;<br>  }</pre><p>and then to add it to a view:</p><pre>textView {<br>              text = &quot;Failed to connect to the internet&quot;<br>              addRuleSet(errorStyle)<br>          }</pre><p>The `classRuleSet()` function creates a ruleset with a CSS class selector. If you want to create a custom css selector you can use</p><pre>val customSelectorRuleSet = stringRuleSet(&quot;ul #id&quot;) {<br>      color = Color(&quot;323243&quot;)<br>  }</pre><p>And then add it to a view the same way as above.</p><h3>Components</h3><p>Kunafa has two concepts, views and component. The view is the basic building block of the UI. It is basically a wrapper around HTML DOM elements. Every view contains an HTML element, but adds many functionalities around it. It has helper functions for easy ui creation. Unless you want to add new functionality to the core of Kunafa, you shouldn’t extend the view classes. To build complicated UI blocks, you can use the views DSL or Components.</p><p>For example, this a reusable ui block of user details row with an image and a name:</p><pre>fun View.userDetailsView(imageUrl: String, userFullName: String) {<br>      horizontalLayout {<br>          imageView {<br>              element.src = imageUrl<br>              style {<br>                  width = 50.px<br>                  height = 50.px<br>              }<br>          }<br>          textView {<br>              text = userFullName<br>          }<br>      }<br>  }</pre><p>and then it can be called like this:</p><pre>page {<br>          verticalLayout {<br>              userDetailsView(&quot;/image/1.png&quot;, &quot;First user name&quot;)<br>              userDetailsView(&quot;/image/2.png&quot;, &quot;Second user name&quot;)<br>              userDetailsView(&quot;/image/3.png&quot;, &quot;Third user name&quot;)<br>          }<br>      }</pre><p>So what are components? The view itself is what appears on the screen. But how do you listen to its lifecycle events? Enter components. Components are wrappers around a view to make it easier to listen to the view lifecycle events, and to make it easy to have a detached view that is not yet added to the DOM. For example, if we wan’t to wrap `userDetailsView` inside a components, it will be like this:</p><pre>class UserDetailsView(val imageUrl: String, val userFullName: String) : <strong>Component()</strong> {<br>      override fun <strong>View?.getView()</strong>: View {<br>          return horizontalLayout {<br>              style {<br>                  width = matchParent<br>              }<br>              imageView {<br>                  element.src = imageUrl<br>                  style {<br>                      width = 50.px<br>                      height = 50.px<br>                  }<br>              }<br>              textView {<br>                  text = userFullName<br>                  style {<br>                      width = weightOf(1)<br>                  }<br>              }<br>          }<br>      }<br>  }</pre><p>The function `View?.getView()` is the only function that needs to be implemented, and it should return only one view.</p><h4>Listening to view lifecycle</h4><p>Now that we have a component, we can listen to the view lifecycle events:</p><pre>class UserDetailsView(val imageUrl: String, val userFullName: String) : Component() {<br>      override fun onViewMounted(lifecycleOwner: LifecycleOwner) {<br>          console.log(&quot;View mounted&quot;)<br>      }</pre><pre>      override fun onViewRemoved(lifecycleOwner: LifecycleOwner) {<br>          console.log(&quot;View removed&quot;)<br>      }</pre><pre>      override fun View?.getView(): View {<br>          return horizontalLayout {<br>              style {<br>                  width = matchParent<br>              }<br>              imageView {<br>                  element.src = imageUrl<br>                  style {<br>                      width = 50.px<br>                      height = 50.px<br>                  }<br>              }<br>              textView {<br>                  text = userFullName<br>                  style {<br>                      width = weightOf(1)<br>                  }<br>              }<br>          }<br>      }<br>  }</pre><p>The view has four lifecycle events: `viewWillMount`, `onViewMounted`, `viewWillBeRemoved`, and `onViewRemoved`</p><h3>Routing</h3><p>Routing should be easy and intuitive. In Kunafa it feels very natural. To specify that a certain view should be mounted at a certain path, simply wrap it with a `route()` function. For example:</p><pre>page {<br>          verticalLayout {<br>              link(&quot;/&quot;) { text = &quot;Home&quot; }<br>              link(&quot;/about&quot;) { text = &quot;About&quot; }</pre><pre>              route(&quot;/&quot;, isExact = true) {<br>                  textView { <br>                      text = &quot;Home page&quot;<br>                  }<br>              }<br>              route(&quot;/about&quot;) {<br>                  textView { <br>                      text = &quot;About page&quot;<br>                  }<br>              }<br>          }<br>      }</pre><p>The `link` is a wrapper around the anchor `a` view. The view inside the `route` function will be mounted when the browser path matches the path given to the route. Notice the `isExact` in the home route so that the home page will only be matched when the browser path is exactly `/`.</p><h4>Nested routes</h4><p>You can have nested routes be calling the `route` function inside another `route` function. Fo example to have a `/about/contact` and `/about/team` routes, it can be as follows:</p><pre>route(&quot;/about&quot;) {<br>                  verticalLayout {<br>                      textView {<br>                          text = &quot;About page&quot;<br>                      }</pre><pre>                  route(&quot;/contact&quot;) {<br>                          textView {<br>                              text = &quot;Contact us&quot;<br>                          }<br>                      }<br>                      route(&quot;/team&quot;) {<br>                          textView {<br>                              text = &quot;Our awesome team&quot;<br>                          }<br>                      }<br>                  }<br>              }</pre><p>Notice that we don’t need to pass the `/about` in the nested routes. as the route path will be relative to its parent route. But what if we need it to be absoulte? Simple, set the `isAbsolute` flag to true as follows.</p><pre>route(&quot;/about/team&quot;, isAbsolute = true) {<br>                          textView {<br>                              text = &quot;Our awesome team&quot;<br>                          }<br>                      }</pre><p>There are more to routing, such as path parameters and getting parent route path. But that will be in a detailed tutorial.</p><h3>Conclusion</h3><p>So that’s Kunafa 0.2.0. We like the way it has evolved until now, and we find it very enjoyable to work with. We will keep on writing the documentation for it, and will try to publish complete tutorials and example to make it easier to get started with Kunafa.<br>We would really like to hear from you. Give it a try and let us know what you think. Also, don’t forget to join <a href="https://join.slack.com/t/kunafa/shared_invite/enQtNTczNjM2NDcwMjU4LWFiY2VkOTI5MTMxNjQ4OTcyNTBjZmNmYmQxZThhMjg4NWI2NWZkNDg2MTNjNTYyODUwZjczZmUyMmQ2MjJjMGM">us at Slack here</a>, and <a href="https://github.com/Kabbura/Kunafa">leave us a star in Github</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ee5237aea5b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-kotlin-chronicle/kunafa-easy-to-use-high-level-framework-in-kotlin-for-front-end-web-development-ee5237aea5b">Kunafa: Easy to use, high level framework in Kotlin for front-end web-development</a> was originally published in <a href="https://medium.com/the-kotlin-chronicle">The Kotlin Chronicle</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>