Scripting quick prototypes in WebSharper can sometimes be troublesome. If for each prototype, a new project has to be created or code needs to be commented/uncommented, it can become quite demotivating as too many steps are required. In F#, .fsx
files are a great tool to script disposable code.
Write some isolated functions, run on FSI and then forget about it.
In my previous posts, I have covered multiple aspects on how WebSharper can be used to make nice webapps by using animations, by tapping into external JS libaries or by using the built in router in UI.Next to make SPA. Today I would like to cover another aspect which is essential for making useful webapps - Forms.
WebSharper.UI.Next exposes a set of functions to animate elements on the page. Today we will see how we can use these functions to create an animated menu with UI.Next.
The documentation for animation can be found here.
The documentation has links to multiple important components of an animation.
In this tutorial, we will only use the Anim.Simple
. It is a function defined in Anim
module which helps in creating an animation.
In my previous posts I explained how to use WebSharper in different ways with Sitelet to build complete backend + frontend web app and with UI.Next to build reactive frontend. If you built the samples, you would have realised that for every changes, a compilation is required to build the JS files. Last week @Tobias_Burger asked me whether I knew a way to improve developer feedback loop when developing web app with WebSharper and that is the subject of this post - Improving developer feedback loop in WebSharper.UI.Next with F#.
Lately I have been playing extensively with WebSharper and have been working on improving the structure and reusability of Bootstrap components built with WebSharper. I like writing HTML from F# as it allows me to reuse code by using namespaces and modules to group reusable functions and elements. Over the last couple of month, I have tried many ways to make functions which facilitate the creation of Bootstrap components and tried many ways to group them into meaningful modules so that it is easily findable for the next time I want to use them. Out of all the solutions I’ve tried, only one really stood out and it is what I want to share today - Method chaining to build Bootstrap components.
When building web apps with WebSharper in F#, one of the most common question is: How do we integrate external JS library with WebSharper in F#?
It is indeed an interesting question since one of the good side of JS is the number of good libraries out there which will save you a lot of time and effort.
WebSharper provides directives to call external JS libraries within F#. Today I would like to explore how we can integrate a JS libraries into our WebSharper project with UI.Next
.
I will demonstrate how you can extend WebSharper.JQuery
to add a tag input functionality with autocompletion.
For the tag input and formatting we will use Bootstrap Tags Input library and to provide autocompletion, we will use Typeahead.js.
F# + WebSharper is an awesome combination to build web application. The only problem is that if you want to build a webapp larger than a to-do list, it’s hard to find examples to use as references. It is even harder to find tutorials that touches on overall design and answer questions like: How should I start? Where should I put the code? How should I separate the code, put it in different files, with different namespaces or modules? How many layers?
Last week I wrote a post on how I handle latency and exception while interacting with REST api in F# using computation expression and WebSharper.
The first part on computation expression was quite detailed but the second part on WebSharper was mostly code snippets with very little explanations.
Today I want to rectify that by showing you how I am using WebSharper UI.Next to build a simplistic single page application (SPA
).