Skip to content

Commit de461f5

Browse files
authored
Merge pull request #2175 from strictdoc-project/mettta/_add_narrative_node_view
UI: add narrative node view
2 parents b29ecf6 + 1c0e97b commit de461f5

File tree

11 files changed

+112
-11
lines changed

11 files changed

+112
-11
lines changed

docs/strictdoc_02_feature_map.sdoc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ DATE: @GIT_COMMIT_DATETIME
77
REQ_PREFIX: SDOC-FEAT-
88
OPTIONS:
99
ENABLE_MID: True
10-
REQUIREMENT_STYLE: Inline
11-
REQUIREMENT_IN_TOC: False
10+
REQUIREMENT_STYLE: Narrative
1211

1312
[GRAMMAR]
1413
ELEMENTS:

strictdoc/backend/sdoc/grammar/grammar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
;
120120
121121
RequirementStyleChoice[noskipws]:
122-
'Inline' | 'Simple' | 'Table' | 'Zebra'
122+
'Inline' | 'Simple' | 'Narrative' | 'Table' | 'Zebra'
123123
;
124124
125125
RequirementHasTitleChoice[noskipws]:

strictdoc/backend/sdoc/models/document_config.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ def get_requirement_style_mode(self) -> str:
9595
"Simple",
9696
):
9797
return "simple"
98+
if self.requirement_style == "Narrative":
99+
return "narrative"
98100
if self.requirement_style == "Table":
99101
return "table"
100102
if self.requirement_style == "Zebra":

strictdoc/export/html/_static/base.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ body {
120120

121121
* { box-sizing: border-box; }
122122

123+
sdoc-scope {
124+
display: contents;
125+
}
126+
123127
/* scrollbar */
124128

125129
* {

strictdoc/export/html/_static/node.css

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,11 @@ sdoc-node[show-node-type-name] sdoc-requirement {
1212
}
1313

1414
sdoc-node[show-node-type-name]::before {
15-
/* content: '[' attr(show-node-type-name) ']'; */
1615
content: attr(show-node-type-name);
1716
position: absolute;
1817
top: calc(2 * var(--base-rhythm));
1918
right: calc(4 * var(--base-rhythm));
20-
z-index: -1;
2119

22-
/* font-size: var(--font-size-xxsm); */
2320
font-size: 10px;
2421
font-family: var(--code-font-family);
2522
font-weight: 600;
@@ -31,11 +28,14 @@ sdoc-node[show-node-type-name]::before {
3128
border: var(--requirement-border-width, 1px) solid var(--requirement-border-color, #bfbfbf);
3229

3330
color: var(--requirement-label-color);
34-
/* background-color: var(--requirement-bg-dark-color); */
3531
background-color: var(--color-bg-contrast);
32+
}
3633

37-
/* color: var(--color-bg-contrast);
38-
background-color: var(--requirement-border-color); */
34+
sdoc-node[node-view="narrative"][show-node-type-name]::before {
35+
top: calc(1 * var(--base-rhythm));
36+
right: calc(1 * var(--base-rhythm));
37+
padding: calc(0.5 * var(--base-rhythm));
38+
border: var(--base-border);
3939
}
4040

4141
/* sdoc-node */

strictdoc/export/html/_static/requirement.css

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,92 @@ sdoc-requirement-field-label {
241241
padding-bottom: 0;
242242
}
243243

244+
/* requirement-view="narrative" */
245+
246+
sdoc-requirement[requirement-view="narrative"] {
247+
display: flex;
248+
flex-direction: column;
249+
background: none;
250+
background-color: transparent;
251+
border: none;
252+
}
253+
254+
[requirement-view="narrative"] sdoc-requirement-title {
255+
border: none;
256+
outline: none;
257+
background: none;
258+
background-color: transparent;
259+
padding: 0;
260+
margin-bottom: var(--base-padding);
261+
grid-column: 1 / -1;
262+
}
263+
264+
[requirement-view="narrative"] sdoc-requirement-field {
265+
padding: 0;
266+
}
267+
268+
[requirement-view="narrative"] sdoc-requirement-field[data-field-type="singleline"] {
269+
/* to make it a single FLEX line */
270+
display: flex;
271+
font-size: var(--font-size-sm);
272+
line-height: calc(var(--font-size-sm) * 1.5);
273+
}
274+
275+
[requirement-view="narrative"] sdoc-requirement-field-label {
276+
/* show them as pseudo-elements: sdoc-requirement-field::before */
277+
display: none;
278+
}
279+
280+
[requirement-view="narrative"] sdoc-requirement-field::before {
281+
flex-grow: 1;
282+
content: attr(data-field-label) ':';
283+
font-family: var(--code-font-family);
284+
font-weight: 500;
285+
font-size: var(--font-size-xsm);
286+
line-height: inherit;
287+
text-transform: uppercase;
288+
font-variant: small-caps;
289+
color: var(--requirement-label-color);
290+
word-break: normal;
291+
display: flex;
292+
padding-right: var(--base-rhythm);
293+
/*
294+
affects field 'pseudo' labels in all fields;
295+
make them lighter:
296+
*/
297+
opacity: 0.8;
298+
}
299+
300+
[requirement-view="narrative"] .requirement_fields_group-secondary sdoc-requirement-field > * {
301+
/*
302+
affects field content in the secondary scope only;
303+
make them lighter:
304+
*/
305+
opacity: 0.6;
306+
}
307+
308+
[requirement-view="narrative"] .requirement__parent-uid,
309+
[requirement-view="narrative"] .requirement__child-uid {
310+
/*
311+
affects UID in links;
312+
make them lighter:
313+
*/
314+
font-weight: normal;
315+
}
316+
317+
[requirement-view="narrative"] .requirement_fields_group-primary {
318+
display: block;
319+
order: 99; /* to push to the end */
320+
margin-top: var(--base-rhythm);
321+
border-top: var(--base-border);
322+
padding-top: var(--base-padding);
323+
}
324+
325+
[requirement-view="narrative"] .requirement_fields_group-primary sdoc-requirement-field {
326+
margin-bottom: var(--base-padding);
327+
color: var(--color-fg-contrast);
328+
}
329+
244330
/* section */
245331

246332
sdoc-section,

strictdoc/export/html/_static/requirement__temporary.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
/* requirement: parent / child / file */
1212

1313
ul.requirement__link {
14-
font-size: .85em;
14+
font-size: .85rem;
1515
line-height: 1.4;
1616
list-style: none;
1717
padding: 0;

strictdoc/export/html/templates/components/node/index.jinja

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
{%- endif %}
3232
{%- endif %}
3333
node-role="{{ node_type }}"
34+
{% if sdoc_entity.is_requirement %}
35+
node-view="{{ sdoc_entity.get_requirement_style_mode() }}"
36+
{%- endif -%}
3437
{%- if node_type_string is not none and node_type_string != 'TEXT' %}
3538
show-node-type-name="{{ node_type_string }}"
3639
{%- endif %}

strictdoc/export/html/templates/components/node_field/files/index.jinja

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{%- set requirement_file_links = view_object.traceability_index.get_requirement_file_links(sdoc_entity) %}
44
{%- if requirement_file_links %}
55
<sdoc-requirement-field-label>file relations:</sdoc-requirement-field-label>
6-
<sdoc-requirement-field data-field-label="files">
6+
<sdoc-requirement-field data-field-label="file relations">
77
<ul class="requirement__link">
88
{%- for link, markers in requirement_file_links %}
99
{%- for marker in markers %}

strictdoc/export/html/templates/components/requirement/index.jinja

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,18 @@
2121
{% set title_number = true %}
2222
{% set truncated_statement = false %}
2323
{% include "components/node_field/title/index.jinja" %}
24+
<sdoc-scope class="requirement_fields_group-secondary">
2425
{% include "components/node_field/meta/index.jinja" %}
26+
</sdoc-scope>
27+
<sdoc-scope class="requirement_fields_group-primary">
2528
{% include "components/node_field/statement/index.jinja" %}
2629
{% include "components/node_field/rationale/index.jinja" %}
2730
{% include "components/node_field/comments/index.jinja" %}
2831
{% include "components/node_field/multiline/index.jinja" %}
32+
</sdoc-scope>
33+
<sdoc-scope class="requirement_fields_group-secondary">
2934
{% include "components/node_field/links/index.jinja" %}
3035
{% include "components/node_field/files/index.jinja" %}
36+
</sdoc-scope>
3137

3238
</sdoc-requirement>

0 commit comments

Comments
 (0)