Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
frama-c
Commits
2c253760
Commit
2c253760
authored
4 years ago
by
Loïc Correnson
Committed by
Michele Alberti
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[dome] utils
parent
f46225aa
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ivette/src/dome/src/misc/utils.ts
+51
-5
51 additions, 5 deletions
ivette/src/dome/src/misc/utils.ts
ivette/tsconfig.json
+1
-0
1 addition, 0 deletions
ivette/tsconfig.json
with
52 additions
and
5 deletions
ivette/src/dome/src/misc/utils.ts
+
51
−
5
View file @
2c253760
...
@@ -2,12 +2,41 @@
...
@@ -2,12 +2,41 @@
// --- Utilities
// --- Utilities
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
/**
@packageDocumentation
@module dome/misc/utils
*/
import
type
{
CSSProperties
}
from
'
react
'
;
import
type
{
CSSProperties
}
from
'
react
'
;
export
type
ClassSpec
=
type
falsy
=
undefined
|
boolean
|
null
|
''
;
undefined
|
boolean
|
null
|
string
|
{
[
cname
:
string
]:
boolean
|
null
|
undefined
};
export
type
ClassSpec
=
string
|
falsy
|
{
[
cname
:
string
]:
true
|
falsy
};
/**
Utility function to merge various HTML class properties
into a `className` property.
Class specifications can be made of:
- a string, interpreted as a CSS class specification
- an object, with keys corresponding to CSS class associated
to true of falsy value.
- any falsy value, which is discarded
Example of usage:
* ```ts
* const className = classes(
* 'my-base-class',
* condition && 'my-class-when-condition',
* {
* 'my-class-1': cond-1,
* 'my-class-2': cond-2,
* 'my-class-3': cond-3,
* }
* );
* ```
*/
export
function
classes
(
export
function
classes
(
...
args
:
ClassSpec
[]
...
args
:
ClassSpec
[]
):
string
{
):
string
{
...
@@ -24,8 +53,25 @@ export function classes(
...
@@ -24,8 +53,25 @@ export function classes(
return
buffer
.
join
(
'
'
);
return
buffer
.
join
(
'
'
);
}
}
export
type
StyleSpec
=
export
type
StyleSpec
=
falsy
|
CSSProperties
;
undefined
|
boolean
|
null
|
CSSProperties
;
/**
Utility function to merge various CSS style properties
into a single CSS style object.
Each style specification can be made of a CSS object or (discarded)
falsy values.
Example of usage:
* ```ts
* const sty = styles(
* { ... },
* cond-1 && { ... },
* cond-2 && { ... },
* );
* ```
*/
export
function
styles
(
export
function
styles
(
...
args
:
StyleSpec
[]
...
args
:
StyleSpec
[]
...
...
This diff is collapsed.
Click to expand it.
ivette/tsconfig.json
+
1
−
0
View file @
2c253760
...
@@ -100,6 +100,7 @@
...
@@ -100,6 +100,7 @@
"doc/pages"
,
"doc/pages"
,
"src/frama-c"
,
"api"
,
"src/frama-c"
,
"api"
,
"src/dome/src/renderer"
,
"src/dome/src/renderer"
,
"src/dome/src/misc"
,
]
]
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment