sass / libsass-net

A lightweight wrapper around libsass
MIT License
94 stars 35 forks source link

Support for Xamarin Forms css syntax #65

Open dansiegel opened 6 years ago

dansiegel commented 6 years ago

Description

With the introduction of Xamarin Forms 3.0 css is now supported. While most of the css is generally valid css, there is a selector that is not typically supported for web applications. Having the ability to generate the css from Sass would be hugely beneficial but currently the Sass compiler generates an exception. I need a way that I can support compiling sass that uses the derived types syntax:

Selector Example Description
^base ^contentpage Selects all elements with ContentPage as base class, including ContentPage itself. Case irrelevant. This selector isn't present in the CSS specification, and only applies to XF.

Sample

As an example I might want to make all buttons have a transparent background whether I'm using the base Button class or some custom Button class.

^button {
  background-color: transparent;
}
nschonni commented 6 years ago

This might require a change to the Sass language. You would need to request that to the sass/sass repo. I don't think it would be accepted though since it wouldn't match the CSS selector allowed characters https://stackoverflow.com/a/4132824/455535

dansiegel commented 6 years ago

@nschonni I thought each language is handled separately now, and I'm not trying to be so presumptuous as to say that all of Sass should be required to change. Since this is for Xamarin Forms developers, they're already working in .NET so making the change for the .NET library makes the most sense here. Ultimately all I need is some way to tell the Sass compiler to accept the special syntax with a preceding ^

nschonni commented 6 years ago

This is a wrapper for libsass, and libsass won't add features that aren't in the Sass language. You could see if you can figure out a way to monkey patch it here though