ctrSetOption¶
Description: The ctrSetOption Stylus invocation sets global ctr options.
Parameters
ctrSetOption(<option>)ctrSetOption(<option>, {<reset>: false, <once>: false, <ctrrc>: true})
Arguments
<option>- Type:
Object - Desc: The
ctrglobal options to be set
- Type:
<once>- Type:
Boolean | false - Desc: Set options to be applied once to the following
ctrinstance then reverted back to the previous option state
- Type:
<reset>- Type:
Boolean | false - Desc: Resets options back to the “base” defined in
.ctrrc.ymlor to the default options
- Type:
<ctrrc>- Type:
Boolean | true - Desc: Overrides the default
resetaction of resetting back to the “base” disregarding.ctrrc.yml, effectively resetting to the default options
- Type:
Example
Edit
ctrSetOption({
hover: {
duration: 2s
delay: 0.5s
ease: 'ease-in'
}
})
ctr('.test', {
hover: {
on: {
width: 400px
}
non: {
width: 200px
}
}
})
ctr:::setOption:
hover:
duration: 2s
delay: 0.5s
ease: ease-in
.test:
hover:
on:
width: 400px
non:
width: 200px
.test:hover {
width: 400px;
transition-delay: 0.5s;
transition-duration: 2s;
transition-property: width;
transition-timing-function: ease-in;
}
.test:not(:hover) {
width: 200px;
transition-delay: 0.5s;
transition-duration: 2s;
transition-property: width;
transition-timing-function: ease-in;
}
ctrSetOption({
hover: {
duration: 2s
delay: 0.5s
ease: 'ease-in'
}
})
ctr('.test', {
hover: {
on: {
width: 400px
}
non: {
width: 200px
}
}
})
.test:hover {
width: 400px;
transition-delay: 0.5s;
transition-duration: 2s;
transition-property: width;
transition-timing-function: ease-in;
}
.test:not(:hover) {
width: 200px;
transition-delay: 0.5s;
transition-duration: 2s;
transition-property: width;
transition-timing-function: ease-in;
}
ctr:::setOption:
hover:
duration: 2s
delay: 0.5s
ease: ease-in
.test:
hover:
on:
width: 400px
non:
width: 200px
Notes
- Always overwrites previously defined or default options
- In practice, this should not be a replacement for
.ctrrc.yml, but meh, sometime I do - A YAML
optionObject can be declared through an Object with the key ofctr:::option - Multiple instances of
ctr:::setOptionin a YAML file can be achieved through modifier key syntax as suchctr:::setOption:<modifier>:- Regex:
^ctr:::setOption
- Regex:
ctrSetVariable¶
Description: The ctrSetVariable Stylus invocation sets global ctr variables.
Parameters
ctrSetVariable(<variable>)ctrSetVariable(<variable>, {<reset>: false, <once>: false, <ctrrc>: true, <overwrite: false>})
Arguments
<variable>- Type:
Object - Desc: The global
ctrvariables to be set
- Type:
<once>- Type:
Boolean | false - Desc: Set variables to be applied once to the following
ctrinstance then reverted back to the previous variable state
- Type:
<reset>- Type:
Boolean | false - Desc: Resets variables back to the “base” defined in
.ctrrc.ymlor to an empty Object
- Type:
<ctrrc>- Type:
Boolean | true - Desc: Overrides the default
resetaction of resetting back to the “base” disregarding.ctrrc.yml, effectively resetting to an empty Object
- Type:
<overwrite>- Type:
Boolean | false - Desc: Overwrites previously set variables
- Type:
Example
Edit
ctrSetVariable({
red: #c0392b
white: #ecf0f1
})
ctr('.test', {
width: 200px
color: '$white$'
background: '$red$'
})
ctr:::setVariable:
red: '#c0392b'
white: '#ecf0f1'
.test:
width: 200px
color: $white$
background: $red$
.test {
width: 200px;
color: #ecf0f1;
background: #c0392b;
}
ctrSetVariable({
red: #c0392b
white: #ecf0f1
})
ctr('.test', {
width: 200px
color: '$white$'
background: '$red$'
})
.test {
width: 200px;
color: #ecf0f1;
background: #c0392b;
}
ctr:::setVariable:
red: '#c0392b'
white: '#ecf0f1'
.test:
width: 200px
color: $white$
background: $red$
Notes
- The intended use of
ctrvariables is to replace Stylus variables - YAML syntax:
ctr:::setVar:- In YAML you can only set the
<variable>Object since there is not way to pass the second argument in YAML
- In YAML you can only set the
- Multiple instances of
ctr:::setVariablein a YAML file can be achieved through modifier key syntax as suchctr:::setVariable:<modifier>:- Regex:
^ctr:::setVariable
- Regex:
- Alias:
ctrSetVar
ctrSetReset¶
Description: The ctrSetReset Stylus invocation resets all values set by other “set” invocations.
Parameters
ctrSetReset()ctrSetReset({<variable>: {}, <option>: {}})
Arguments
<variable>- Type:
Object | Boolean - Desc: Sets default variables or if the variables should be reset
- Type:
<option>- Type:
Object | Boolean - Desc: Sets default options or if the options should be reset
- Type:
Notes
- Could be useful, but I would shy away unless needed
ctrReset¶
Description: The ctrReset Stylus invocation resets everything.
Parameters
ctrReset()ctrReset({<variable>: {}, <option>: {}})
Arguments
<variable>- Type:
Object | Boolean - Desc: Sets default variables
- Type:
<option>- Type:
Object | Boolean - Desc: Sets default options
- Type:
Notes
- Somewhat like the nuclear option, I typically use it for debugging purposes or if shit get fucked and I need a new sheet of ice