-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
updates to investment status component #424
updates to investment status component #424
Conversation
b65dd0c
to
6f379b6
Compare
5afaede
to
95da091
Compare
I wonder if we can use |
@@ -14,28 +13,18 @@ | |||
#} | |||
|
|||
{% if projectCode %} | |||
<div class="status-bar grid-row"> | |||
<dl class="status-bar__section column-one-quarter"> | |||
<div class="l-container"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
padding-left: ($gutter / 2) + (($gutter / 3) * 2); | ||
} | ||
} | ||
|
||
dt { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we shouldn't be using element selectors here. I know it's not part of this change but might be worth addressing whilst you're looking at that component.
If we're sticking to BEM we should be trying to use classname selectors rather than element selectors.
I have updated this component to use the |
4cb4a43
to
cf9c335
Compare
<dl> | ||
{% for meta in props.meta %} | ||
{% if meta.value %} | ||
<div class="c-meta-item"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't have div
as sibling of dl
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/sibling/child
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't have div as sibling of dl.
According to MDN its permitted content
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It says there:
WHATWG HTML allows wrapping each name-value group in a
<dl>
element in a<div>
element.
As far as I can tell there's still no consensus on this issue.
I wonder if the macro should deal with loops at all. The isLabelHidden
is also a global setting and there seems to be no way of using that for a specific item.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if there was a macro that creates a single key/value pair? And then maybe It could be used in a loop using map
filter.
6f379b6
to
e7d260a
Compare
@@ -6,16 +6,20 @@ | |||
+ &:nth-child(even) { | |||
margin-left: $baseline-grid-unit; | |||
} | |||
|
|||
& + & { | |||
margin-left: $default-spacing-unit; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
|
||
.c-meta-item__value { | ||
color: $text-colour; | ||
color: $grey-1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Render Meta fields for Investment | ||
# @param {object[]} props.meta - Array of meta objects | ||
#} | ||
{% macro InvestmentMeta (props) %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This name feels very heavily tied to its content but I wonder if it needs to. The macro is just rendering a list of meta-item and it doesn't need to care if they're in investment or not.
This macro could be MetaData
and added to _macros/common.njk
(as much as I hate its generic name)?
e7d260a
to
2d12ba8
Compare
cf9c335
to
3fd2686
Compare
@tyom @teneightfive updates up for this |
@import "../settings"; | ||
|
||
.c-meta-bar { | ||
margin-top: $default-spacing-unit; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be set in assemblies.
@@ -1,4 +1,5 @@ | |||
{% extends "_layouts/two-column.njk" %} | |||
{% from "_macros/entities.njk" import MetaItem %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this used here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no - added here so its globally available
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just import in datahub-layout.njk
like all the other Macros. Then we don't have random imports scattered around. Also allows us to see which macros are available to the views at a glance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah my bad! this is meant to be in with all the others
|
||
{% if investmentData.archived %} | ||
{{ Meta({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could also do this without creating a new macro:
{{
[
{
label: 'Project code',
value: investmentStatus.projectCode
},
{
label: 'Valuation',
value: investmentStatus.valuation
}
] | map(callAsMacro('MetaItem')) | join | safe
}}
Or set the data it in controller and just use one liner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Over cornflakes I have been pondering this... The reason I didn't go with the MetaItem
macro is because it is just using div
s and it felt like there was a need for a dl
here. Hence the creation of Meta
component.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could make it configurable like we do with other macros. e.g. pass el
prop into macro.
src/templates/_macros/common.njk
Outdated
#} | ||
{% macro Meta(props) %} | ||
{% if props.meta | length %} | ||
<dl class="c-meta-bar"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This component seems unique to one use case so far. Is it really a component? Could we avoid creating new macros for a single use case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This component seems unique to one use case so far. Is it really a component? Could we avoid creating new macros for a single use case?
will do - ill add it in as described above
6991049
to
be30239
Compare
459efea
to
7db4867
Compare
be30239
to
c7cf278
Compare
1af823a
to
e853641
Compare
c7cf278
to
260c8a1
Compare
e853641
to
93b7cab
Compare
@import "../settings"; | ||
|
||
.c-meta-list { | ||
margin-top: $default-spacing-unit; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if it appears as the first element? Could use a sibling selector to tell it only to apply a top margin if it has a preceding element:
.c-meta-list {
* + & {
margin-top: $default-spacing-unit;
}
}
margin-top: $default-spacing-unit; | ||
|
||
.c-meta-item { | ||
margin-right: $default-spacing-unit; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use a sibling selector to set a left margin:
.c-meta-item {
* + & {
margin-left: $default-spacing-unit;
}
}
|
||
{% if investmentData.archived %} | ||
{{ MetaList({ | ||
meta: [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
items
?
src/templates/_macros/common.njk
Outdated
<dl class="c-meta-list"> | ||
{% for meta in props.meta %} | ||
{% if meta.value %} | ||
<div class="c-meta-item"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we have a <div>
as a child element of a <dl>
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should try to fit it into HTML semantics at this stage. We could use use non-semantic elements for now and refactor once we have a better idea how these are used across the apps (in groups or as individual elements).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed 👍 we can align later when we know what this should be doing
260c8a1
to
662195d
Compare
d1238e8
to
3e22c0e
Compare
3e22c0e
to
addf027
Compare
Updates to the markup and styles in the investment status component
Multipart PR, part of base branch
feature/investment-project-stages
and PR #395