# @crisp32/stylescript

> A CSS superset designed to be directly integrated with a Node.JS webserver.

Latest version **1.0.2** (published 2020-02-19) · ISC license · 0 weekly downloads

## Install

```sh
npm install @crisp32/stylescript
pnpm add @crisp32/stylescript
yarn add @crisp32/stylescript
bun add @crisp32/stylescript
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2020-02-19 |
| First published | 2020-02-19 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 8 |
| Unpacked size | 41.8 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Connell Reffo |
| Maintainers | crisp32 |
| Keywords | StyleScript, CSS Superset, Middleware |

## Links

- npm: https://www.npmjs.com/package/@crisp32/stylescript
- npm.io page: https://npm.io/package/@crisp32/stylescript

## Dependencies (8)

- [fs](https://npm.io/package/fs.md) 0.0.1-security
- [tsc](https://npm.io/package/tsc.md) ^1.20150623.0
- [nodemon](https://npm.io/package/nodemon.md) ^2.0.2
- [ts-node](https://npm.io/package/ts-node.md) ^8.6.2
- [typescript](https://npm.io/package/typescript.md) ^3.7.5
- [@types/node](https://npm.io/package/@types/node.md) ^13.7.1
- [body-parser](https://npm.io/package/body-parser.md) ^1.19.0
- [ts-node-dev](https://npm.io/package/ts-node-dev.md) ^1.0.0-pre.44

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2020-02-19
- 1.0.1 — 2020-02-19
- 1.0.0 — 2020-02-19

## README

<h1><img src="https://github.com/Crisp32/StyleScript/blob/master/icons/stylescript-logo-full.png?raw=true" width="230"></h1>
<br>

<div align="left">
  <img src="https://img.shields.io/badge/node-%3E%3D%206.0.0-brightgreen">
  <img src="https://img.shields.io/badge/license-ISC-blue">
  <img src="https://img.shields.io/badge/language-TypeScript-yellow">
  <img src="https://img.shields.io/badge/developer-Connell Reffo (Crisp32)-red">
 </div>

# Table of Contents
 - [Info](#info)
 - [Installation](#installation)
 - [Dependancies](#dependancies)
 - [Examples](#stylescript-code-examples)
 - [Integration](#integration-with-ts-node)

# Info
StyleScript is a CSS superset designed to be directly integrated with a TypeScript Node.js webserver.

# Dependancies
```json
"dependencies": {
  "@types/node": "^13.7.1",
  "body-parser": "^1.19.0",
  "fs": "0.0.1-security",
  "nodemon": "^2.0.2",
  "ts-node": "^8.6.2",
  "ts-node-dev": "^1.0.0-pre.44",
  "tsc": "^1.20150623.0",
  "typescript": "^3.7.5"
}
```

# Installation
 - Inside of your Node.js project, run **npm install @crisp32/stylescript**
 - You are now ready to use StyleScript in your project

# StyleScript Code Examples
```scss
/* Include Multiple Files (Automatically Assumes *.sscr File Extension) */
%include(./styles1, ./styles2);

/* Variable Declaration */
%var(bgColour, #131313);
%var(txtColour, white);

/* Variable Re-Assignment */
%var(txtColour, lightgrey);

/* Style Script Block Definition */
%testBlock {
  text-align: center;
  color: %txtColour; /* Variable Insertion */
}

div {
  %testBlock; /* Insert Code Block */
  margin-bottom: 5px;
}

```

# Integration With TS-Node
```typescript
import { StyleScript as ss } from "stylescript"; // Can also use require("stylescript").StyleScript;

const express = require("express");
const parser = require("body-parser");
const app = express();
const port = 3000;

// Use Body Parser Middleware
app.use(parser.urlencoded({ extended:true }));

// StyleScript Auto Compile Middleware
app.use(async (req, res, next):void => {
    
    // Set __dirname to the Root Directory of the Project
    ss.autoCompile(req, res, next, __dirname, {
        highlightColour: "blue" // Can be used in SSCR { background-color: %highlightColour; }
    });
});

// Another way of Serving StyleScript
app.get("/someStyles", async (req, res):void => {
  res.setHeader("content-type", "text/css");
  res.send(ss.compile("./styles.sscr"), {
    someVar: "red",
    divWidth: "20px"
  });
});

// Simple Page that will Reference the example.sscr Style Sheet
app.get("/", (req, res):void => res.send(`
  <link rel="stylesheet" type="text/css" href="example.sscr">
  <div>Hello World!</div>
`));

// Start Server
app.listen(port, ():void => console.log(`SSCR Example Listening on Port ${port}!`));
```

---
_Source: https://npm.io/package/@crisp32/stylescript · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
