init commit
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
list: user.code_common_function
|
||||
code.language: css
|
||||
code.language: scss
|
||||
-
|
||||
|
||||
# reference
|
||||
attribute: attr
|
||||
env
|
||||
url
|
||||
var
|
||||
variable: var
|
||||
# mathematical
|
||||
calc
|
||||
calculate: calc
|
||||
clamp
|
||||
max
|
||||
min
|
||||
# color
|
||||
HSL: hsl
|
||||
hue sat light: hsl
|
||||
HSLA: hsla
|
||||
lab
|
||||
LCH: lch
|
||||
RGB: rgb
|
||||
red green blue: rgb
|
||||
RGBA: rgba
|
||||
color
|
||||
# image functions
|
||||
linear gradient: linear-gradient
|
||||
# counter functions
|
||||
counter
|
||||
counters
|
||||
symbols
|
||||
# filter
|
||||
blur
|
||||
brightness
|
||||
contrast
|
||||
drop shadow: drop-shadow
|
||||
grayscale
|
||||
hue rotate: hue-rotate
|
||||
invert
|
||||
opacity
|
||||
saturate
|
||||
sepia
|
||||
# grid
|
||||
fit content: fit-content
|
||||
min max: minmax
|
||||
repeat
|
||||
# transform
|
||||
matrix
|
||||
rotate
|
||||
scale
|
||||
skew
|
||||
translate
|
||||
@@ -0,0 +1,81 @@
|
||||
from talon import Context, Module, actions
|
||||
|
||||
from ..tags.operators import Operators
|
||||
|
||||
mod = Module()
|
||||
global_ctx = Context()
|
||||
ctx = Context()
|
||||
ctx.matches = """
|
||||
code.language: css
|
||||
code.language: scss
|
||||
"""
|
||||
|
||||
mod.list("css_at_rule", desc="List of CSS @rules")
|
||||
mod.list("css_unit", desc="List of CSS units")
|
||||
mod.list("css_global_value", desc="CSS-wide values")
|
||||
|
||||
global_ctx.lists["self.css_unit"] = {
|
||||
# distance (length)
|
||||
"char": "ch",
|
||||
"em": "em",
|
||||
"rem": "rem",
|
||||
"pixels": "px",
|
||||
"points": "pt",
|
||||
"view height": "vh",
|
||||
"view width": "vw",
|
||||
# angle
|
||||
"degrees": "deg",
|
||||
"radians": "rad",
|
||||
"turn": "turn",
|
||||
# duration (time)
|
||||
"seconds": "s",
|
||||
"millis": "ms",
|
||||
# resolution
|
||||
"dots per pixel": "dppx",
|
||||
# flexible length (flex) - grid
|
||||
"fraction": "fr",
|
||||
}
|
||||
|
||||
global_ctx.lists["self.css_at_rule"] = {
|
||||
# regular
|
||||
"charset": "charset",
|
||||
"import": "import",
|
||||
"namespace": "namespace",
|
||||
# conditional group
|
||||
"media": "media",
|
||||
"supports": "supports",
|
||||
# other nested
|
||||
"page": "page",
|
||||
"font face": "font-face",
|
||||
"keyframes": "keyframes",
|
||||
# CSS Modules
|
||||
"value": "value",
|
||||
}
|
||||
|
||||
global_ctx.lists["self.css_global_value"] = ["initial", "inherit", "unset", "revert"]
|
||||
|
||||
|
||||
operators = Operators(
|
||||
MATH_ADD=" + ",
|
||||
MATH_SUBTRACT=" - ",
|
||||
MATH_MULTIPLY=" * ",
|
||||
MATH_DIVIDE=" / ",
|
||||
MATH_AND=" and ",
|
||||
MATH_OR=" or ",
|
||||
MATH_GREATER_THAN=" > ",
|
||||
MATH_GREATER_THAN_OR_EQUAL=" >= ",
|
||||
MATH_LESS_THAN=" < ",
|
||||
MATH_LESS_THAN_OR_EQUAL=" <= ",
|
||||
)
|
||||
|
||||
|
||||
@ctx.action_class("user")
|
||||
class UserActions:
|
||||
def code_get_operators() -> Operators:
|
||||
return operators
|
||||
|
||||
def code_insert_function(text: str, selection: str):
|
||||
substitutions = {"1": text}
|
||||
if selection:
|
||||
substitutions["0"] = selection
|
||||
actions.user.insert_snippet_by_name("functionCall", substitutions)
|
||||
@@ -0,0 +1,45 @@
|
||||
code.language: css
|
||||
code.language: scss
|
||||
-
|
||||
|
||||
tag(): user.code_comment_block_c_like
|
||||
tag(): user.code_functions_common
|
||||
tag(): user.code_libraries
|
||||
tag(): user.code_operators_math
|
||||
|
||||
settings():
|
||||
user.code_public_variable_formatter = "DASH_SEPARATED"
|
||||
|
||||
block: user.code_block()
|
||||
|
||||
attribute [<user.text>]:
|
||||
name = user.formatted_text(text or "", "DASH_SEPARATED")
|
||||
user.insert_between("[{name}", "]")
|
||||
|
||||
prop <user.text>:
|
||||
name = user.formatted_text(text, "DASH_SEPARATED")
|
||||
user.insert_between("{name}: ", ";")
|
||||
|
||||
# for media/supports queries, or if you don't like prop
|
||||
rule <user.text>:
|
||||
name = user.formatted_text(text, "DASH_SEPARATED")
|
||||
insert("{name}: ")
|
||||
|
||||
value <user.number_string> [{user.css_unit}]: "{number_string}{css_unit or ''}"
|
||||
value <user.number_string> point <digit_string> [{user.css_unit}]:
|
||||
"{number_string}.{digit_string}{css_unit or ''}"
|
||||
|
||||
(value | state) {user.css_global_value}: "{css_global_value}"
|
||||
value <user.text>: user.insert_formatted(text, "DASH_SEPARATED")
|
||||
|
||||
variable <user.text>:
|
||||
name = user.formatted_text(text, "DASH_SEPARATED")
|
||||
insert("var(--{name})")
|
||||
|
||||
op var: user.insert_between("var(--", ")")
|
||||
|
||||
at {user.css_at_rule}: "@{css_at_rule} "
|
||||
unit {user.css_unit}: insert(css_unit)
|
||||
|
||||
[value] current color: "currentColor"
|
||||
op important: " !important"
|
||||
Reference in New Issue
Block a user