FsTachyons 1.0.0
dotnet add package FsTachyons --version 1.0.0
NuGet\Install-Package FsTachyons -Version 1.0.0
<PackageReference Include="FsTachyons" Version="1.0.0" />
paket add FsTachyons --version 1.0.0
#r "nuget: FsTachyons, 1.0.0"
// Install FsTachyons as a Cake Addin #addin nuget:?package=FsTachyons&version=1.0.0 // Install FsTachyons as a Cake Tool #tool nuget:?package=FsTachyons&version=1.0.0
FsTachyons
open FsTachyons
open FsTachyons
open FsTachyons.Tac
Elem.h1 [ Attr.class' (tac [ f3; f1_m; f_headline_l ])]
[ Text.raw "Hello World!" ]
// Produces: <h1 class="f3 f1-m f-headline-l">Title</h1>
Note: FsTachyons is included for demonstration purposes only.
FsTachyons is an F# API for the functional CSS library Tachyons, functional CSS for humans.
Key Features
- Automatically helps build complex class strings, via
tac []
. - Facilitates the discoverability of Tachyons classes.
- Use native F# to produce class strings.
- Easily extended by creating custom classes.
Design Goals
- Provide discoverable functions for all Tachyons classes.
- Can be integrated into any F# markup DSL.
- Easily learned by someone with knowledge of Tachyons.
Overview
FsTachyons maps all of the Tachyons CSS classes to functions in the Tac
module. These types can be combined together to form class strings using the tac []
helper function, or composed using the +
operator.
To escape the characters which are valid in the CSS spec, but not F#, the following augmentations to the Tachyons class are made:
- Leading
.
is removed (i.e.,.red
becomesred
). -
are replaced by_
(i.e.,.b--red
becomesb__red
).
Usage with FsTachyons
FsTachyons has modules for elements & attributes, this allows us to import the FsTachyons.Tac
which make class string definitions more terse.
open FsTachyons
open FsTachyons
open FsTachyons.Tac
// <p class="measure lh-copy">Lorem ipsum</p>
Elem.p [ Attr.class' (tac [ measure; lh_copy ])]
[ Text.raw "Lorem ipsum" ]
// <h1 class="f3 f1-m f-headline-l">Title</h1>
Elem.h1 [ Attr.class' (tac [ f3; f1_m; f_headline_l ])]
[ Text.raw "Hello World!" ]
// <a class="f6 link dim br1 ph3 pv2 mb2 dib white bg-black" href="#0">Button Text</a>
Elem.a [ Attr.class' (tac [ f6; link; dim; br1; ph3; pv2; dib; white; bg_black ]) ]
[ Text.raw "Button Text" ]
Usage with Feliz
open Feliz
open FsTachyons
open FsTachyons.Tac
// <p class="measure lh-copy">Lorem ipsum</p>
Elem.p [ prop.className [ tac [ measure; lh_copy ] ]
prop.text "Lorem ipsum" ]
// <h1 class="f3 f1-m f-headline-l">Title</h1>
Elem.h1 [ prop.className [ tac [ f3; f1_m; f_headline_l ] ]
prop.text "Hello World!" ]
// <a class="f6 link dim br1 ph3 pv2 mb2 dib white bg-black" href="#0">Button Text</a>
Elem.a [ prop.className [ tac [ f6; link; dim; br1; ph3; pv2; dib; white; bg_black ] ]
prop.text "Button Text" ]
Usage with Giraffe.ViewEngine
With Giraffe's approach to HTML generation, we must reference the class functions via the Tac
module.
open FsTachyons
open Giraffe.ViewEngine
// <p class="measure lh-copy">Lorem ipsum</p>
p [ _class (tac [Tac.measure; Tac.lh_copy ])]
[ rawText "Lorem ipsum" ]
// <h1 class="f3 f1-m f-headline-l">Title</h1>
h1 [ _class (tac [ Tac.f3; Tac.f1_m; Tac.f_headline_l ])]
[ rawText "Hello World!" ]
// <a class="f6 link dim br1 ph3 pv2 mb2 dib white bg-black" href="#0">Button Text</a>
a [ _class (tac [ Tac.f6; Tac.link; Tac.dim; Tac.br1; Tac.ph3; Tac.pv2; Tac.dib; Tac.white; Tac.bg_black ]) ]
[ rawText "Button Text" ]
Find a bug?
There's an issue for that.
License
Built with ♥ by NHLPA Engineering in Toronto, ON. Licensed under MIT.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- FSharp.Core (>= 4.5.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 244 | 9/16/2022 |