Skip to content

1.0.0-beta #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Initial commit.
  • Loading branch information
sciborrudnicki committed Sep 15, 2024
commit f289986d818f090f1d926e9064016fb23741e34b
12 changes: 12 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.idea/
node_modules/
yarn.lock
package-lock.json
.*
!.csscomb.json
!.gitignore
!.gitattributes
!.hound.yml
!.scss-lint.yml
!.stylelintrc.json
temp
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# SassString

This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 14.2.0.

## Code scaffolding

Run `ng generate component component-name --project sass-string` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project sass-string`.
> Note: Don't forget to add `--project sass-string` or else it will be added to the default project in your `angular.json` file.

## Build

Run `ng build sass-string` to build the project. The build artifacts will be stored in the `dist/` directory.

## Publishing

After building your library with `ng build sass-string`, go to the dist folder `cd dist/sass-string` and run `npm publish`.

## Running unit tests

Run `ng test sass-string` to execute the unit tests via [Karma](https://karma-runner.github.io).

## Further help

To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
1 change: 1 addition & 0 deletions index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@forward "src/lib";
44 changes: 44 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html

module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
jasmine: {
// you can add configuration options for Jasmine here
// the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
// for example, you can disable the random execution with `random: false`
// or set a specific seed with `seed: 4321`
},
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
jasmineHtmlReporter: {
suppressAll: true // removes the duplicated traces
},
coverageReporter: {
dir: require('path').join(__dirname, '../../coverage/sass-string'),
subdir: '.',
reporters: [
{ type: 'html' },
{ type: 'text-summary' }
]
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
restartOnFileChange: true
});
};
11 changes: 11 additions & 0 deletions ng-package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
"dest": "../../dist/sass-string",
"lib": {
"entryFile": "src/public-api.ts"
},
"assets": [
"./src/lib/**/*.scss",
"*.scss"
]
}
56 changes: 56 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"name": "@angular-package/sass-string",
"version": "1.0.0-beta",
"author": "@angular-package <contact@angular-package.dev>",
"homepage": "https://angular-package.github.io/spectre.css",
"description": "Extension for sass modules and new modules.",
"main": "./index.scss",
"license": "MIT",
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org"
},
"devDependencies": {
"stylelint": "^15.10.3",
"stylelint-config-prettier-scss": "^1.0.0",
"stylelint-config-standard-scss": "^11.0.0",
"stylelint-order": "^6.0.3"
},
"peerDependencies": {
"sass": "^1.78.0"
},
"scripts": {
"dart": "dart compile-sass.dart"
},
"repository": {
"type": "git",
"url": "https://github.com/angular-package/sass-string"
},
"bugs": {
"url": "https://github.com/angular-package/sass-string/issues"
},
"keywords": [
"@angular-package",
"sass:string",
"scss",
"string"
],
"funding": [
{
"type": "individual",
"url": "https://checkout.revolut.com/pay/048b10a3-0e10-42c8-a917-e3e9cb4c8e29"
},
{
"type": "individual",
"url": "https://docs.angular-package.dev/donate/cryptocurrency"
},
{
"type": "patreon",
"url": "https://www.patreon.com/angularpackage"
},
{
"type": "github",
"url": "https://github.com/sponsors/angular-package"
}
]
}
6 changes: 6 additions & 0 deletions spec.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Not active.

// @use "./src/lib/spec";
// @use "../sass-string";

// @debug sass-string.ends-with("primary dark", dark); // true
14 changes: 14 additions & 0 deletions src/lib/_index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@forward "string.ends-with.function";
@forward "string.index.function";
@forward "string.is-lower-case.function";
@forward "string.is-upper-case.function";
@forward "string.is.function";
@forward "string.join.function";
@forward "string.of.function";
@forward "string.replace-multiple.function";
@forward "string.replace.function";
@forward "string.split.function";
@forward "string.starts-with.function";
@forward "string.to-map.function";
@forward "string.unquote.function";
@forward "sass:string" hide index, split, unquote;
33 changes: 33 additions & 0 deletions src/lib/_string.ends-with.function.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Sass.
@use 'sass:meta';
@use 'sass:string';

// Completed
// The `string.ends-with()` function determines whether `$string` ends with `$search-string` at `$position`.
// @param `$string` String to determine that it ends with `$search-string` at `$position`.
// @param `$search-string` String to determine that ends in `$string` at `$position`.
// @param `$position` Position at which `$search-string` is expected to be found.
// @returns The returned value is a `bool` indicating whether `$string` ends with `$search-string` at `$position`.
@function ends-with($string, $search-string, $position: null) {
@if not (meta.type-of($string) == string) {
@error "$string: #{$string} is not string";
}
@if not (meta.type-of($search-string) == string) {
@error "$search-string: #{$search-string} is not string";
}
$index: string.index($string, $search-string);
@if if($position, $position and $index == $position, true) {
@return ($index - 1) + string.length($search-string) == string.length($string);
}
@return false;
}

// Examples.
// $-text: 'Primary color red';

// @debug ends-with($-text, 'red'); // true
// @debug ends-with($-text, 'color red'); // true

// Position.
// @debug ends-with($-text, 'color red', 9); // true
// @debug ends-with($-text, 'color red', 4); // false
48 changes: 48 additions & 0 deletions src/lib/_string.index.function.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Sass.
@use 'sass:list';
@use 'sass:meta';
@use 'sass:string';

// Completed
// The `string.index()` function returns index of required `$substring` and additional indexes of `$substrings`.
// @param `$string` String to check whether it contains required `$substring` and additional `$substrings`.
// @param `$substring` A substring to find in `$string`.
// @arbitrary `$substrings...` Additional substrings to find in `$string`.
// @returns The returned value is index of `$substring` and additional indexes of `$substrings`.
@function index($string, $substring, $substrings...) {
@if not (meta.type-of($string) == string) {
@error "$string: #{$string} is not string";
}
$result: ();
@each $substring in list.join($substring, $substrings, comma) {
$result: list.append(
$result,
meta.type-of($substring) == string
and string.index($string, $substring)
or null,
comma
);
}
@if list.length($result) > 0 {
@return list.length($result) > 1
and $result
or list.nth($result, 1);
}
@return null;
}

// Examples.
// Single
// @debug index("Helvetica Neue", "Helvetica"); // 1
// @debug index("Helvetica Neue", "Neue"); // 11

// Multiple
// @debug index("Helvetica Neue", "Helvetica", "Neue"); // 1, 11
// @debug index("Helvetica Neue", "Helvetica", "Neue", "Wrong"); // 1, 11, null
// @debug index("Helvetica Neue", "Helvetica", "Neue", "Wrong", true); // 1, 11, null, null

// null
// @debug index("Helvetica Neue", "d"); // null

// Different type of the `$string`
// @debug index(true, "Helvetica"); // error
25 changes: 25 additions & 0 deletions src/lib/_string.is-lower-case.function.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Sass.
@use 'sass:meta';
@use 'sass:string';

// Completed
// The `string.is-lower-case()` function determines `$string` is written in small letters.
// @param `$string` String to determine is written in small letters.
// @returns The returned value is `bool` indicating `$string` is written in small letters.
@function is-lower-case($string) {
@if not (meta.type-of($string) == string) {
@error "$string: #{$string} is not string";
}
@for $i from 1 through string.length($string) {
$letter: string.slice($string, $i, $i);
@if ($letter != string.to-lower-case($letter)) {
@return false;
}
}
@return true;
}

// Examples.
// @debug is-lower-case('test test test'); // true
// @debug is-lower-case('TEST TEST TEST'); // false
// @debug is-lower-case('TEST test TEST'); // false
25 changes: 25 additions & 0 deletions src/lib/_string.is-upper-case.function.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Sass.
@use 'sass:meta';
@use 'sass:string';

// Completed
// The `string.is-upper-case()` function determines `$string` is written in capital letters.
// @param `$string` String to determine is written in capital letters.
// @returns The returned value is `bool` indicating `$string` is written in capital letters.
@function is-upper-case($string) {
@if not (meta.type-of($string) == string) {
@error "$string: #{$string} is not string";
}
@for $i from 1 through string.length($string) {
$letter: string.slice($string, $i, $i);
@if ($letter != string.to-upper-case($letter)) {
@return false;
}
}
@return true;
}

// Examples.
// @debug is-upper-case('TEST TEST TEST'); // true
// @debug is-upper-case('test test test'); // false
// @debug is-upper-case('TEST test TEST'); // false
25 changes: 25 additions & 0 deletions src/lib/_string.is.function.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Sass.
@use 'sass:list';
@use 'sass:meta';

// Completed
// The `string.is()` function checks whether `$value` is `string` type.
// @param `$value` Any value to check against `string` type.
// @arbitrary `$values...` Additional values to check against `string` type.
// @return The returned value is `bool` indicating whether `$value` is `string` type.
@function is($value, $values...) {
@each $value in list.join(($value,), $values, comma) {
@if not (meta.type-of($value) == string) {
@return false;
}
}
@return true;
}

// Examples.
// @debug is(test); // true
// @debug is(test, test1, test2); // true
// @debug is(test, test1, 2); // false

// @debug is(1); // false
// @debug is(1, 2); // false
36 changes: 36 additions & 0 deletions src/lib/_string.join.function.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Sass.
@use 'sass:list';
@use 'sass:meta';
@use 'sass:string';

// Completed
// The `string.join()` function returns the `string` built from `$elements` separated by `$delimiter` in original elements order.
// @param `$delimiter` The delimiter to add between `$elements`.
// @param `$elements...` Elements to join to returned string of `color`, `list`, `number` or `string` type with the `$delimiter`.
// @returns The returned value is a `string` built from `$elements` with `$delimiter`.
@function join($delimiter, $elements...) {
$string: '';
@each $element in $elements {
@if list.index(color list number string, meta.type-of($element)) {
@each $element in $element {
$string: string.insert($string, #{$element}#{$delimiter or ''}, -1);
}
}
}
@return string.slice($string, 1, calc((string.length($delimiter) + 1) * -1));
}

// Examples.
// @debug join('-');
// @debug join('-', 'a', 'b', 'c'); // a-b-c
// @debug join('-', '', 'a', 'b', 'c'); // -a-b-c
// @debug join('-', 'a', 'b', 'c', ''); // a-b-c-
// @debug join('-', '', 'a', 'b', 'c', ''); // a-b-c-
// @debug join('-', 'a', ('b', 'c')); // a-b-c
// @debug join('-', a, b, c); // a-b-c

// Join number.
// @debug join('-', a, 1, b, 2, c, 3); // a-1-b-2-c-3

// Join color.
// @debug join('-', silver, orange, green, red, blue, yellow); // silver-orange-green-red-blue-yellow
Loading