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
c4b3b22e
Commit
c4b3b22e
authored
4 years ago
by
Loïc Correnson
Browse files
Options
Downloads
Patches
Plain Diff
[dome] linted layout
parent
7befa5fb
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
ivette/.eslintignore
+0
-2
0 additions, 2 deletions
ivette/.eslintignore
ivette/src/dome/src/misc/utils.ts
+25
-10
25 additions, 10 deletions
ivette/src/dome/src/misc/utils.ts
ivette/src/dome/src/renderer/layout/boxes.tsx
+39
-20
39 additions, 20 deletions
ivette/src/dome/src/renderer/layout/boxes.tsx
with
64 additions
and
32 deletions
ivette/.eslintignore
+
0
−
2
View file @
c4b3b22e
...
@@ -8,5 +8,3 @@ coverage
...
@@ -8,5 +8,3 @@ coverage
lib
lib
# don't lint the generated API
# don't lint the generated API
src/api
src/api
# lint Dome step by step
src/dome/src/renderer/layout
This diff is collapsed.
Click to expand it.
ivette/src/dome/src/misc/utils.ts
+
25
−
10
View file @
c4b3b22e
...
@@ -2,28 +2,43 @@
...
@@ -2,28 +2,43 @@
// --- Utilities
// --- Utilities
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
type
specClass
=
import
type
{
CSSProperties
}
from
'
react
'
;
export
type
ClassSpec
=
undefined
|
boolean
|
null
|
string
|
undefined
|
boolean
|
null
|
string
|
{
[
cname
:
string
]:
boolean
|
null
|
undefined
};
{
[
cname
:
string
]:
boolean
|
null
|
undefined
};
export
function
classes
(
export
function
classes
(
...
args
:
spec
Class
[]
...
args
:
Class
Spec
[]
):
string
{
):
string
{
const
buffer
:
string
[]
=
[];
const
buffer
:
string
[]
=
[];
args
.
forEach
((
spec
)
=>
{
args
.
forEach
((
cla
)
=>
{
if
(
spec
!==
undefined
&&
spec
!==
null
)
{
if
(
cla
)
{
if
(
typeof
(
spec
)
===
'
string
'
&&
spec
!==
''
)
buffer
.
push
(
spec
);
if
(
typeof
(
cla
)
===
'
string
'
&&
cla
!==
''
)
buffer
.
push
(
cla
);
else
if
(
typeof
(
spec
)
===
'
object
'
)
{
else
if
(
typeof
(
cla
)
===
'
object
'
)
{
const
cs
=
Object
.
keys
(
spec
);
const
cs
=
Object
.
keys
(
cla
);
cs
.
forEach
((
c
)
=>
{
if
(
spec
[
c
])
buffer
.
push
(
c
);
});
cs
.
forEach
((
c
)
=>
{
if
(
cla
[
c
])
buffer
.
push
(
c
);
});
}
}
}
}
});
});
return
buffer
.
join
(
'
'
);
return
buffer
.
join
(
'
'
);
}
}
// --- please the linter
export
type
StyleSpec
=
undefined
|
boolean
|
null
|
CSSProperties
;
export
default
{};
export
function
styles
(
...
args
:
StyleSpec
[]
):
CSSProperties
|
undefined
{
let
empty
=
true
;
let
buffer
=
{};
args
.
forEach
((
sty
)
=>
{
if
(
sty
&&
typeof
(
sty
)
===
'
object
'
)
{
empty
=
false
;
buffer
=
{
...
buffer
,
...
sty
};
}
});
return
(
empty
?
undefined
:
buffer
);
}
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
This diff is collapsed.
Click to expand it.
ivette/src/dome/src/renderer/layout/boxes.tsx
+
39
−
20
View file @
c4b3b22e
...
@@ -26,11 +26,12 @@
...
@@ -26,11 +26,12 @@
- [[Scroll]] scrolls its content
- [[Scroll]] scrolls its content
Inside a box, you may add `<Space/>` and `<Filler/>` to separate items.
Inside a box, you may add `<Space/>` and `<Filler/>` to separate items.
Inside a grid, you may also use `<Space/>` or an empty `<div/>` for empty cells.
Inside a grid, you may also use `<Space/>` or an empty `<div/>` for empty
cells.
<strong>Warning:</strong> large elements will be clipped if they overflow.
<strong>Warning:</strong> large elements will be clipped if they overflow.
If you want to add scrolling capabilities to some item that does not manage
overflow
If you want to add scrolling capabilities to some item that does not manage
natively, place it inside a `<Scroll/>` sub-container.
overflow
natively, place it inside a `<Scroll/>` sub-container.
@packageDocumentation
@packageDocumentation
@module dome/layout/boxes
@module dome/layout/boxes
...
@@ -39,6 +40,7 @@
...
@@ -39,6 +40,7 @@
import
React
from
'
react
'
;
import
React
from
'
react
'
;
import
*
as
Dome
from
'
dome
'
;
import
*
as
Dome
from
'
dome
'
;
import
{
Title
}
from
'
dome/controls/labels
'
;
import
{
Title
}
from
'
dome/controls/labels
'
;
import
{
classes
,
styles
}
from
'
dome/misc/utils
'
;
import
'
./style.css
'
;
import
'
./style.css
'
;
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
...
@@ -54,10 +56,10 @@ const makeBox = (
...
@@ -54,10 +56,10 @@ const makeBox = (
morestyle
?:
React
.
CSSProperties
,
morestyle
?:
React
.
CSSProperties
,
)
=>
{
)
=>
{
const
{
children
,
className
,
style
,
...
others
}
=
props
;
const
{
children
,
className
,
style
,
...
others
}
=
props
;
const
allClasses
=
class
Name
?
boxClasses
+
'
'
+
className
:
boxClasses
;
const
allClasses
=
class
es
(
className
,
boxClasses
)
;
const
allStyles
=
more
style
?
(
style
?
Object
.
assign
({},
style
,
morestyle
)
:
morestyle
)
:
style
;
const
allStyles
=
style
s
(
style
,
morestyle
)
;
return
(
return
(
<
div
className
=
{
allClasses
}
style
=
{
allStyles
}
{
...
others
}
>
<
div
className
=
{
allClasses
}
style
=
{
allStyles
}
{
...
others
}
>
{
children
}
{
children
}
</
div
>
</
div
>
);
);
...
@@ -70,32 +72,38 @@ const makeBox = (
...
@@ -70,32 +72,38 @@ const makeBox = (
/**
/**
Horizontal box (extends horizontally, no overflow).
Horizontal box (extends horizontally, no overflow).
*/
*/
export
const
Hbox
=
(
props
:
DivProps
)
=>
makeBox
(
'
dome-xBoxes-hbox dome-xBoxes-box
'
,
props
);
export
const
Hbox
=
(
props
:
DivProps
)
=>
makeBox
(
'
dome-xBoxes-hbox dome-xBoxes-box
'
,
props
);
/**
/**
Vertical box (extends vertically, no overflow).
Vertical box (extends vertically, no overflow).
*/
*/
export
const
Vbox
=
(
props
:
DivProps
)
=>
makeBox
(
'
dome-xBoxes-vbox dome-xBoxes-box
'
,
props
);
export
const
Vbox
=
(
props
:
DivProps
)
=>
makeBox
(
'
dome-xBoxes-vbox dome-xBoxes-box
'
,
props
);
/**
/**
Compact Horizontal box (fixed dimensions, no overflow).
Compact Horizontal box (fixed dimensions, no overflow).
*/
*/
export
const
Hpack
=
(
props
:
DivProps
)
=>
makeBox
(
'
dome-xBoxes-hbox dome-xBoxes-pack
'
,
props
);
export
const
Hpack
=
(
props
:
DivProps
)
=>
makeBox
(
'
dome-xBoxes-hbox dome-xBoxes-pack
'
,
props
);
/**
/**
Compact Vertical box (fixed dimensions, no overflow).
Compact Vertical box (fixed dimensions, no overflow).
*/
*/
export
const
Vpack
=
(
props
:
DivProps
)
=>
makeBox
(
'
dome-xBoxes-vbox dome-xBoxes-pack
'
,
props
);
export
const
Vpack
=
(
props
:
DivProps
)
=>
makeBox
(
'
dome-xBoxes-vbox dome-xBoxes-pack
'
,
props
);
/**
/**
Horizontally filled box (fixed height, maximal width, no overflow).
Horizontally filled box (fixed height, maximal width, no overflow).
*/
*/
export
const
Hfill
=
(
props
:
DivProps
)
=>
makeBox
(
'
dome-xBoxes-hbox dome-xBoxes-fill
'
,
props
);
export
const
Hfill
=
(
props
:
DivProps
)
=>
makeBox
(
'
dome-xBoxes-hbox dome-xBoxes-fill
'
,
props
);
/**
/**
Vertically filled box (fixed width, maximal height, no overflow).
Vertically filled box (fixed width, maximal height, no overflow).
*/
*/
export
const
Vfill
=
(
props
:
DivProps
)
=>
makeBox
(
'
dome-xBoxes-vbox dome-xBoxes-fill
'
,
props
);
export
const
Vfill
=
(
props
:
DivProps
)
=>
makeBox
(
'
dome-xBoxes-vbox dome-xBoxes-fill
'
,
props
);
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
// --- Scrolling & Spacing
// --- Scrolling & Spacing
...
@@ -104,23 +112,26 @@ export const Vfill = (props: DivProps) => makeBox('dome-xBoxes-vbox dome-xBoxes-
...
@@ -104,23 +112,26 @@ export const Vfill = (props: DivProps) => makeBox('dome-xBoxes-vbox dome-xBoxes-
/**
/**
Scrolling container.
Scrolling container.
*/
*/
export
const
Scroll
=
(
props
:
DivProps
)
=>
makeBox
(
'
dome-xBoxes-scroll dome-container
'
,
props
);
export
const
Scroll
=
(
props
:
DivProps
)
=>
makeBox
(
'
dome-xBoxes-scroll dome-container
'
,
props
);
/**
/**
Rigid space between items in a box.
Rigid space between items in a box.
*/
*/
export
const
Space
=
(
props
:
DivProps
)
=>
makeBox
(
'
dome-xBoxes-space
'
,
props
);
export
const
Space
=
(
props
:
DivProps
)
=>
makeBox
(
'
dome-xBoxes-space
'
,
props
);
/**
/**
Extensible space between items in a box.
Extensible space between items in a box.
*/
*/
export
const
Filler
=
(
props
:
DivProps
)
=>
makeBox
(
'
dome-xBoxes-filler
'
,
props
);
export
const
Filler
=
(
props
:
DivProps
)
=>
makeBox
(
'
dome-xBoxes-filler
'
,
props
);
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
// --- Grids
// --- Grids
// --------------------------------------------------------------------------
// --------------------------------------------------------------------------
export
interface
GridProps
extends
DivProps
{
columns
?:
string
;
}
export
interface
GridProps
extends
DivProps
{
columns
?:
string
}
/**
/**
Grid box container.
Grid box container.
...
@@ -128,8 +139,9 @@ export interface GridProps extends DivProps { columns?: string; }
...
@@ -128,8 +139,9 @@ export interface GridProps extends DivProps { columns?: string; }
Layout its children in a multi-column grid. Each column is specified by its
Layout its children in a multi-column grid. Each column is specified by its
width, following the CSS Grid Layout `grid-template-columns` property.
width, following the CSS Grid Layout `grid-template-columns` property.
The rows are populated with children from left-to-right, using one column at a time.
The rows are populated with children from left-to-right, using one column at
Items layout can be modified by using CSS Grid Layout item properties.
a time. Items layout can be modified by using CSS Grid Layout item
properties.
Example: `<Grid columns="25% auto auto"> ... </Grid>`
Example: `<Grid columns="25% auto auto"> ... </Grid>`
*/
*/
...
@@ -162,13 +174,20 @@ export interface FolderProps {
...
@@ -162,13 +174,20 @@ export interface FolderProps {
The head label is clickable to fold/unfold its contents.
The head label is clickable to fold/unfold its contents.
*/
*/
export
const
Folder
=
(
props
:
FolderProps
)
=>
{
export
const
Folder
=
(
props
:
FolderProps
)
=>
{
const
{
settings
,
defaultUnfold
=
false
,
indent
=
18
,
label
,
title
,
children
}
=
props
;
const
{
settings
,
defaultUnfold
=
false
,
indent
=
18
,
label
,
title
,
children
,
}
=
props
;
const
[
unfold
,
onClick
]
=
Dome
.
useSwitch
(
settings
,
defaultUnfold
);
const
[
unfold
,
onClick
]
=
Dome
.
useSwitch
(
settings
,
defaultUnfold
);
const
icon
=
unfold
?
'
TRIANGLE.DOWN
'
:
'
TRIANGLE.RIGHT
'
;
const
icon
=
unfold
?
'
TRIANGLE.DOWN
'
:
'
TRIANGLE.RIGHT
'
;
const
display
=
unfold
?
'
none
'
:
'
block
'
;
const
display
=
unfold
?
'
none
'
:
'
block
'
;
return
(
return
(
<
Vpack
>
<
Vpack
>
<
Hpack
onClick
=
{
onClick
}
><
Title
icon
=
{
icon
}
label
=
{
label
}
title
=
{
title
}
/></
Hpack
>
<
Hpack
onClick
=
{
onClick
}
>
<
Title
icon
=
{
icon
}
label
=
{
label
}
title
=
{
title
}
/>
</
Hpack
>
<
Vpack
style
=
{
{
display
,
marginLeft
:
indent
}
}
>
<
Vpack
style
=
{
{
display
,
marginLeft
:
indent
}
}
>
{
children
}
{
children
}
</
Vpack
>
</
Vpack
>
...
...
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