utilities

CSS Classes

Roseworx ships with a bunch of css helper classes so you can easily and consistently style your front end without writing extra css code. Here is a list of all the classes you can use;

Spacing
Class Description
.rwxs-m-sm Small margin in all directions
.rwxs-m-md Medium margin in all directions
.rwxs-m-lg Large margin in all directions
.rwxs-m-no No Margin in all directions
.rwxs-p-sm Small padding in all directions
.rwxs-p-md Medium padding in all directions
.rwxs-p-lg Large padding in all directions
.rwxs-p-no No padding in all directions
.rwxs-m-l-sm Small left margin
.rwxs-m-l-md Medium left margin
.rwxs-m-l-lg Large left margin
.rwxs-m-l-no No left margin
.rwxs-p-l-sm Small left padding
.rwxs-p-l-md Medium left padding
.rwxs-p-l-lg Large left padding
.rwxs-p-l-no No left padding
.rwxs-m-r-sm Small right margin
.rwxs-m-r-md Medium right margin
.rwxs-m-r-lg Large right margin
.rwxs-m-r-no No right margin
.rwxs-p-r-sm Small right padding
.rwxs-p-r-md Medium right padding
.rwxs-p-r-lg Large right padding
.rwxs-p-r-no No right padding
.rwxs-m-t-sm Small top margin
.rwxs-m-t-md Medium top margin
.rwxs-m-t-lg Large top margin
.rwxs-m-t-no No top margin
.rwxs-p-t-sm Small top padding
.rwxs-p-t-md Medium top padding
.rwxs-p-t-lg Large top padding
.rwxs-p-t-no No top padding
.rwxs-m-b-sm Small bottom margin
.rwxs-m-b-md Medium bottom margin
.rwxs-m-b-lg Large bottom margin
.rwxs-m-b-no No bottom margin
.rwxs-p-b-sm Small bottom padding
.rwxs-p-b-md Medium bottom padding
.rwxs-p-b-lg Large bottom padding
.rwxs-p-b-no No bottom padding
Type
Class Description
.rwxt-light Light font weight
.rwxt-normal Normal font weight
.rwxt-bold Bold font weight
.rwxt-extra-bold Extra bold font weight
.rwxt-small Text smaller
.rwxt-uppercase Text to uppercase
.rwxt-text-center Align text center
.rwxt-text-right Align text to the right
.rwxt-underline Unerlines
.rwxt-no-underline Removes underline
.h1 Styles an element like a h1
.h2 Styles an element like a h2
.h3 Styles an element like a h3
.h4 Styles an element like a h4
.h5 Styles an element like a h5
.h6 Styles an element like a h6
Colors
SCSS Variable Description
.rwxc-background-black Black background color
.rwxc-background-grey Grey background color
.rwxc-background-dark-grey Dark Grey background color
.rwxc-background-white White background color
.rwxc-background-orange Orange background color
.rwxc-background-red Red background color
.rwxc-background-blue Blue background color
.rwxc-background-light-blue Light Blue background color
.rwxc-background-turquoise Turquoise background color
.rwxc-background-green Green background color
.rwxc-background-light-green Light Green background color
.rwxc-background-yellow Yellow background color
.rwxc-background-purple Purple background color
.rwxc-background-pink Pink background color
.rwxc-background-brown Brown background color
.rwxc-color-black Black color
.rwxc-color-grey Grey color
.rwxc-color-dark-grey Dark Grey color
.rwxc-color-white White color
.rwxc-color-orange Orange color
.rwxc-color-red Red color
.rwxc-color-blue Blue color
.rwxc-color-light-blue Light Blue color
.rwxc-color-turquoise Turquoise color
.rwxc-color-green Green color
.rwxc-color-light-green Light Green color
.rwxc-color-yellow Yellow color
.rwxc-color-purple Purple color
.rwxc-color-pink Pink color
.rwxc-color-brown Brown color
Utilities
Class Description
.rwxu-flex-center Aligns inner content to center in both directions
.rwxu-absolute-center Aligns inner content to center in both directions with absolute positioning
.rwxu-full-size Makes element the full size of the closest parent with position:relative

SCSS Mixins

Roseworx also ships with mixins which you can easily incorporate and use directly in your own SCSS files to inherit common and useful styles.

Mixin Description
@include flex-center Aligns inner content to center in both directions
@include absolute-center Aligns inner content to center in both directions with absolute positioning
@include full-size Makes element the full size of the closest parent with position:relative
@include change-link-color($color) Because our links use a pseudo-element for the underline, this mixin gives you an easier way to change the color of a link. (e.g .navigation ul li{@include change-link-color($white);} will change all a tags properly to white in each .navigation ul li)
@include snap-down-from($breakpoint){...put styles here} Allows you to apply styles specifically for below the specified breakpoint.
@include snap-up-from($breakpoint){...put styles here} Allows you to apply styles specifically for above the specified breakpoint

SCSS Variable Overrides

Roseworx has a bunch of configurable variables to tailor the framework to your own specific requirements.

Form Variables
SCSS Variable Value Type Description
$form-color-base CSS color Base color for form items
$form-color-secondary CSS color Secondary color for form items
$form-color-focus CSS color Color of the focus ring when a form item has focussed
$form-color-valid CSS color Color of the form item when it is considered valid.
$form-color-invalid CSS color Color of the form item when it is considered invalid.
$form-item-size CSS Length The size of form items.
Table Variables
SCSS Variable Value Type Description
$table-color-base CSS color Base color for tables
$table-color-secondary CSS color Secondary color for tables
$table-color-highlight CSS color The color of the table row when it is either hovered (.highlightable modifer) or every odd row (.colored modifier)
$table-height-limit CSS Length When rwx-table attribute is present on a table, it will be limited to this height to allow for scrolling.
$table-cell-width-limit CSS Length The minimum width for each table cell up to 'md' breakpoint so cells dont appear too squashed.
Button Variables
SCSS Variable Value Type Description
$button-size CSS Length Miniumum size of a button
$button-color-base CSS color Base color for buttons (the color a button will appear by default without any color modifier)
Color Variables
SCSS Variable Value Type Description
$black CSS color Black
$grey CSS color Grey
$dark-grey CSS color Dark Grey
$white CSS color White
$orange CSS color Orange
$red CSS color Red
$blue CSS color Blue
$light-blue CSS color Light Blue
$turquoise CSS color Turquoise
$green CSS color Green
$light-green CSS color Light Green
$yellow CSS color Yellow
$purple CSS color Purple
$pink CSS color Pink
$brown CSS color Brown
Type Variables
SCSS Variable Value Type Description
$font-size-small CSS Length Font size for elements which extend or have the .small class.
$font-size-base CSS Length Default font size for all type
$line-height-base CSS Length Default line height for type
$h1-size CSS Length H1 element font size
$h2-size CSS Length H2 element font size
$h3-size CSS Length H3 element font size
$h4-size CSS Length H4 element font size
$h5-size CSS Length H5 element font size
$h6-size CSS Length H6 element font size
$underline-headings Boolean (True | False) If ALL headings have an underline or not
$font-base CSS Font Family The font family for general type
$font-heading CSS Font Family The font family for headings specifically
$font-color-base CSS color The color all type accross the framework will appear
$font-link-color CSS color The color all links and their underline will appear
$list-item-counter-color CSS color The color that the counter for list items will appear
$section-seperators Boolean (True | False) If section seperator lines should be enabled or not
$section-seperator-color CSS color The color of the seperator line which section tags have
$card-background-color CSS color The background color for all cards
$card-border-color CSS color The border color for all cards
$card-indent-color CSS color The indent background color for all cards
$card-icon-color CSS color The color of the icon for all cards
Grid Variables
SCSS Variable Value Type Description
$grid-item-gutter CSS Length The size of the padding either side of a grid item
$breakpoint-mini CSS Length Mini breakpoint
$breakpoint-sm CSS Length Small breakpoint
$breakpoint-md CSS Length Medium breakpoint
$breakpoint-lg CSS Length Large breakpoint
$breakpoint-xl CSS Length Extra Large breakpoint
Spacing
SCSS Variable Value Type Description
$small-spacing CSS Length the size of the small spacing that the .rwxs classes create. (also used within the roseworx core for various things to maintain standard spacing)
$medium-spacing CSS Length the size of the medium spacing that the .rwxs classes create. (also used within the roseworx core for various things to maintain standard spacing)
$large-spacing CSS Length the size of the large spacing that the .rwxs classes create. (also used within the roseworx core for various things to maintain standard spacing)
Tabs
Variable Value Type Description
$tabs-title-color CSS color The color of the tab titles
$tabs-active-color CSS color The color of the decoration and title when the corresponding tab is active
$tabs-seperator-color CSS color The color of the seperator between the tab titles and the tabs themselves.
$tabs-title-size CSS Length The font size of the tab titles
Sliders
Variable Value Type Description
$slider-counter-active-color CSS color The color of the counter when the corresponding slide is in view
$slider-counter-inactive-color CSS color The color of the counter when the corresponding slide is not in view
$slider-counter-size CSS Length The size of the counter

Themes

To make things easier for consistent colors, the entire Roseworx framework core initially uses theme color variables. The following table shows which variables are initially set to which theme variables.

$theme-color-base $theme-color-secondary $theme-color-tertiary
$card-border-color $card-background-color $font-link-color
$table-color-base $table-color-secondary $list-item-counter-color
$form-color-base $form-color-secondary $card-indent-color
$slider-counter-active-color $slider-counter-inactive-color $section-seperator-color
$tabs-title-color $tabs-seperator-color $table-color-highlight
$tabs-active-color

You can, of course, still override each of the above variables individually to something different, they do not have to be set to a theme variable.

Because you have to set these variables before importing the Roseworx scss, the Roseworx color scss variables will not be available so you will need to set it directly to a CSS color .

Instead of including all the JS helpers files individually (if you need to use all or the majority of them), you can import them all in one go.

import {rwxCanvas, rwxMath, rwxAnimate, rwxDOM, rwxMisc, rwxGeometry} from 'roseworx/js/helpers/rwxHelpers';

HTML5 Canvas Helpers

import rwxCanvas from 'roseworx/js/helpers/rwxCanvasHelpers';
scale

Void

(

Canvas Node: HTMLElement
Canvas 2d Context: CanvasRenderingContext2D
Width: Number
Height: Number

)

Scales a canvas element to the specified width and height based on the users device pixel ratio so the user gets the best visual experience for the device they are viewing on.

		const canvas = document.getElementById('demo');
        												const ctx = canvas.getContext('2d');
        												const width = 400;
        												const height = 400;
        												rwxCanvas.scale(canvas, ctx, width, height);
        										
drawSector

Void

(

Canvas 2d Context: CanvasRenderingContext2D
Sector Center Point: {x: Number , y: Number}
Sector Outer Radius: Number
Start Angle (in radians): Number
End Angle (in radians): Number

)

Draws a circle sector on the supplied canvas rendering context.

		rwxCanvas.drawSector(ctx, {x:150, y:150}, 150, rwxGeometry.toRadians(270), rwxGeometry.toRadians(360));
        										
drawArc

Void

(

Canvas 2d Context: CanvasRenderingContext2D
Sector Center Point: {x: Number , y: Number}
Arc Outer Radius: Number
Arc Depth: Number
Start Angle (in radians): Number
End Angle (in radians): Number

)

Draws a circle arc on the supplied canvas rendering context.

		rwxCanvas.drawArc(ctx, {x:150, y:150}, 150, 50, rwxGeometry.toRadians(180), rwxGeometry.toRadians(240));
        										

Geometry Helpers

import rwxGeometry from 'roseworx/js/helpers/rwxGeometryHelpers';
toRadians

Number

(

Angle (in degrees): Number

)

Converts the specified angle in to radians.

		const angle = 30;
        												const result = rwxGeometry.toRadians(angle);
        										
getQuadraticBezierLength

Number

(

Start Point: {x: Number , y: Number}
Control Point: {x: Number , y: Number}
End Point: {x: Number , y: Number}

)

Returns an approximate (due to complexity) length of a quadratic bezier curve.

		const start = {x: 50, y: 50};
        												const control = {x: 333, y: 33};
        												const end = {x: 250, y: 250};
        												const result = rwxGeometry.getQuadraticBezierLength(start, control, end);
        										
getDistance

Number

(

Point 1: {x: Number , y: Number}
Point 2: {x: Number , y: Number}

)

Returns a distance between 2 points.

		const point1 = {x: 35, y: 35};
        												const point2 = {x: 265, y: 265};
        												const result = rwxGeometry.getDistance(point1, point2);
        										
isInsideCircle

Boolean

(

Point: {x: Number , y: Number}
Circle Center Point: {x: Number , y: Number}
Radius: Number

)

Checks to see if a point is inside a circle of given centre point and radius.

		const point = {x: 175, y: 175};
        												const circleCenter = {x: 150, y: 150};
        												const radius = 100;
        												const result = rwxGeometry.isInsideCircle(point, circleCenter, radius);
        										
isInsideSector

Boolean

(

Point: {x: Number , y: Number}
Sector Center Point: {x: Number , y: Number}
Radius: Number
Start Angle (in radians): Number
End Angle (in radians): Number

)

Checks to see if a point is inside a sector of a circle.

		const point = {x: 200, y: 50};
        												const sectorCenter = {x: 150, y: 150};
        												const outerRadius = 150;
        												const startAngle = rwxGeometry.toRadians(270);
        												const endAngle = rwxGeometry.toRadians(360);
        												const result = rwxGeometry.isInsideSector(point, sectorCenter, outerRadius, startAngle, endAngle);
        										
isInsideArc

Boolean

(

Point: {x: Number , y: Number}
Arc Center Point: {x: Number , y: Number}
Outer Radius: Number
Inner Radius: Number
Start Angle (in radians): Number
End Angle (in radians): Number

)

Checks to see if a point is inside an arc of a circle.

		const point = {x:50, y:100};
        												const arcCenter = {x:150, y:150};
        												const outerRadius = 150;
        												const innerRadius = 100;
        												const startAngle = rwxGeometry.toRadians(180);
        												const endAngle = rwxGeometry.toRadians(240);
        												const result = rwxGeometry.isInsideArc(point, arcCenter, outerRadius, innerRadius, startAngle, endAngle);
        										
closestPointOnCircumference

{x: Number, y: Number}

(

Point: {x: Number , y: Number}
Circle Center Point: {x: Number , y: Number}
Radius: Number

)

Finds the closest point on a circles circumference relative to a given point.

		const point = {x:130, y:190};
        												const circleCenter {x:150, y:150};
        												const radius = 100;
        												const result = rwxGeometry.closestPointOnCircumference(point, circleCenter, radius);
        										

Animate Helpers

fromTo

Number

(

Start Value: Number
End Value: Number
ID: String
Easing Function: String
Duration: Number
Animation Complete Callback: Function

)

Animates a value from its start value to its end value over a specified duration and with the specified easing. If no duration is specified, 1000 (1 second) will be used. If no easing is specified, 'linear' will be used.

		animate();
        												function animate()
        												{
        													let x = rwxAnimate.fromTo(40, 260, 'circle1x', 'easeInOutQuad', 2000, ()=>{console.log("done")});
        													let y = rwxAnimate.fromTo(40, 260, 'circle1y', 'easeInOutQuad', 2000);
        													window.requestAnimationFrame(animate);	
        												}
        										

For possible easing function values see easing functions.
fromTo method must be invoked from inside a requestAnimationFrame() loop. and the ID parameter must stay the same throughout the entirity of the animation for internal tracking purposes.

fromToBezier

Number

(

Start Value: {x: Number , y: Number}
Control Value 1: {x: Number , y: Number}
Control Value 2: {x: Number , y: Number}
End Value: {x: Number , y: Number}
ID: String
Easing Function: String
Duration: Number
Animation Complete Callback: Function

)

Animates a value from its start value to its end value over a specified duration, with specified easing, VIA specified control points. If no duration is specified, 1000 (1 second) will be used. If no easing is specified, 'linear' will be used.

		animate();
        												function animate()
        												{
        													let {x,y} = rwxAnimate.fromToBezier({x: 40, y:40}, {x: 70, y:300}, {x: 300, y:0}, {x: 260, y:260}, 'circleBezier', 'easeInOutQuint', 2000, ()=>{console.log("fromToBezier done")});
        													window.requestAnimationFrame(animate);
        												}
        										

For possible easing function values see easing functions.
fromToBezier method must be invoked from inside a requestAnimationFrame() loop. The ID parameter must stay the same throughout the entirity of the animation for internal tracking purposes.

Easing Functions
Easing Function Name Description
Linear No Acceleration or Deceleration
easeInQuad Slow Acceleration
easeInCubic Medium Acceleration
easeInQuart Fast Acceleration
easeInQuint Very Fast Acceleration
easeOutQuad Slow Deceleration
easeOutCubic Medium Deceleration
easeOutQuart Fast Deceleration
easeOutQuint Very Fast Deceleration
easeInOutQuad Slow Acceleration until halfway, then Slow Deceleration
easeInOutCubic Medium Acceleration until halfway, then Medium Deceleration
easeInOutQuart Fast Acceleration until halfway, then Fast Deceleration
easeInOutQuint Very Fast Acceleration until halfway, then Very Fast Deceleration

Math Helpers

import rwxMath from 'roseworx/js/helpers/rwxMathHelpers';
randomInt

Number

(

From: Number
To: Number

)

Generates a random number inbetween the specified from and to (including both those numbers)

		const result = rwxMath.randomInt(0,10);
        										
randomFloat

Number

(

From: Number
To: Number

)

Generates a random float inbetween the specified from and to (including both those numbers)

		const result = rwxMath.randomFloat(0,1);
        										

DOM Helpers

import rwxDOM from 'roseworx/js/helpers/rwxDOMHelpers';
hasAncestor

Boolean

(

Element: HTML Element
Any Valid CSS Selector: String

)

Checks to see if the specified element has an ancestor (node above it in the DOM hierarchy) that matches the specified selector.

		const element = document.getElementById('hasAncestorExample');
        												rwxDOM.hasAncestor(element, '.hasThisClass');
        										
slideUp

Void

(

Element: HTML Element
Duration (in seconds): Number
Callback: Function

)

Slides an element up to hide the contents inside. If callback is supplied, it will be ran after then animation has completed.

		const element = document.getElementById('slideUpExample');
        												rwxDOM.slideUp(element, 1, ()=>{console.log("done");});
        										
slideUp Demo
Press the below button to observe the slideUp action.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

slideDown

Void

(

Element: HTML Element
Duration (in seconds): Number
Callback: Function

)

Slides an element down to display the contents inside. If callback is supplied, it will be ran after then animation has completed. A class of .rwx-slide-expanded will be added to the element when it has expanded.

		const element = document.getElementById('slideDownExample');
        												rwxDOM.slideDown(element, 1, ()=>{console.log("done");});
        										
slideDown Demo
Press the below button to observe the slideDown action.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

slideToggle

Void

(

Element: HTML Element
Duration (in seconds): Number
Callback: Function

)

Slides an element down if its contents is currently hidden, or up if its contents is visible. If callback is supplied, it will be ran after each slide animation. A class of .rwx-slide-expanded will be added to the element when it has expanded and removed when unexpanded.

		const element = document.getElementById('slideToggleExample');
        												rwxDOM.slideToggle(element, 1, ()=>{console.log("done");});
        										
slideToggle Demo
Press the below button to observe the slideToggle action.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Misc Helpers

import rwxMisc from 'roseworx/js/helpers/rwxMiscHelpers';
uniqueId

String

Generates a random 10 character hexadecimal ID prefixed with an underscore.

		const result = rwxMisc.uniqueId();
        										
safeCloneObject

Object

(

Reference Object: Object

)

Safely clones an object, removing all references to the original object.

		const obj = {a: "b", c: "d", e: "f"};
        												const result = rwxMisc.safeCloneObject(obj);
        												obj.a = "g";
        										
safeCloneArray

Array

(

Reference Array: Array

)

Safely clones an array, removing all references to the original array.

		const arr = ['a', 'b', 'c', 'd', 'e', 'f'];
        												const result = rwxMisc.safeCloneArray(arr);
        												arr[3] = "g";
        										
safeCloneArrayOfObjects

Array

(

Reference Array: Array

)

Safely clones an array of objects, removing all references to the original array and all references to the objects inside.

		const arr = [{a: "b"}, {c: "d"}, {e: "f"}];
        												const result = rwxMisc.safeCloneArrayOfObjects(arr);
        												arr[0] = {g: "h"};
        												arr[2].e = "i";
        										
shuffleArray

Void

(

Reference Array: Array

)

Randomly shuffles all the items in an array.

		const arr = ['a', 'b', 'c', 'd', 'e', 'f'];
        												const result = rwxMisc.shuffleArray(arr);
        										
setCookie

Void

(

Cookie Name: String
Cookie Value: String
Expiry Length (in days): Number

)

Sets a cookie for the given amount of days. Omit the expiry length attribute to have the cookie expire at the end of the session.

		const cookieName = "RoseWorx";
        												const cookieValue = "Is Great";
        												const expires = 31;
        												const result = rwxMisc.setCookie(cookieName, cookieValue, expires);
        										
getCookie

String

(

Cookie Name: String

)

Gets a cookie with the given cookie name.

		const cookieName = "RoseWorx";
        												const result = rwxMisc.getCookie(cookieName);