GitXplorerGitXplorer
s

cloaked-hipster

public
12 stars
3 forks
0 issues

Commits

List of commits on branch master.
Unverified
96657fd276ba09ffd10268d69aa44155df1316fb

detecting opacity test now passes

sshiftbot committed 13 years ago
Unverified
eca6ba2e16e72ca54a23e080c17b3ee89e8cd305

Merge pull request #1 from tathamoddie/master

sshiftkey-tester committed 13 years ago
Unverified
fc2db3c3ec87a5a2eb37282240be598ca69c78f3

gotcha busted test

sshiftbot committed 13 years ago
Unverified
c528279ed163a88ec686be19e0278fcdb39739c7

introducing the mapper to handle multiple properties

sshiftbot committed 13 years ago
Unverified
a784078d5e10d5fbd72c9aea6f95bd8159176696

more tests for conventions

sshiftbot committed 13 years ago
Unverified
17ae950de7375482746b344c7416edb87d15e723

starting test parsing

sshiftbot committed 13 years ago

README

The README file for this repository.

cloaked-hipster

The Rant

A discussion yesterday about XAML versus HTML degenerated into much debate around how terrible the XAML syntax is for declaring resources.

<Style TargetType="TextBlock" x:Key="TitleText">
  <Setter Property="Background" Value="Blue"/>
  <Setter Property="DockPanel.Dock" Value="Top"/>
  <Setter Property="FontSize" Value="18"/>
  <Setter Property="Foreground" Value="#4E87D4"/>
  <Setter Property="FontFamily" Value="Trebuchet MS"/>
  <Setter Property="Margin" Value="0,40,10,10"/>
</Style>

So very very verbose.

Contrast that with the equivalent CSS:

titletext 
{ 
   background: blue;
   font-size: 18;
   foreground: #4E87D4;
   font-family: Trebuchet MS;
   margin: 40px 10px 10px 0; // note how the order is different
}

The Wager

So one wise-guy, who shall remain nameless, said "Why can't you just use CSS?" and after more debate I ran out of things that were dealbreakers.

So this little sandbox is an experiment - using Twitter Bootstrap as a reference stylesheet - to allow you to use CSS in your XAML apps.

The implementation

I think the best approach for this is to use T4 templates, and I've got a prototype which now works using T4:

<#@ template language="C#" #>
<#@ output extension=".xaml" #>
<#@ assembly name="$(SolutionDir)\CloakedHipster\bin\Debug\CloakedHipster.dll" #>

<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

<#
var conventions = new CloakedHipster.Conventions();
conventions.Use("btn", "Button");
conventions.Use("text", "TextBlock");

Write(CloakedHipster.Transformer.Generate(CssContents, conventions)); #>

</ResourceDictionary>

<#+
string CssContents = "titletext { background: blue; font-size: 18; foreground: #4E87D4; font-family: Trebuchet MS;   margin: 40px 10px 10px 0; }";
#>

And how would you use this?

  1. Open a XAML app
  2. File -> New Item -> Select "New CSS Resource" file -> Add
  3. Paste in CSS contents into value. Save file.
  4. Build process runs T4 engine and spits out a XAML resource file
  5. Reference new resource dictionary in your App.xaml file

Notes:

The use of conventions to resolve styles needs to be thought through - it feels rushed at the moment.

Integrating with the build system to provide feedback about how styles cannot be transformed

  • "style 'titletext' could not be processed as it doesn't have a control defined..."
  • "style 'titletext' has an image which is not included in the project..."

Are you mad?

According to @tathamoddie, yes.