Skip to content
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

Conversation

feedmypixel
Copy link
Contributor

@feedmypixel feedmypixel commented Aug 7, 2017

Updates to the markup and styles in the investment status component

Multipart PR, part of base branchfeature/investment-project-stages and PR #395

screen shot 2017-08-07 at 20 39 54

@ztolley ztolley temporarily deployed to datahub-beta2-pr-424 August 7, 2017 16:59 Inactive
@feedmypixel feedmypixel force-pushed the feature/investment-project-stages branch 4 times, most recently from b65dd0c to 6f379b6 Compare August 7, 2017 19:32
@feedmypixel feedmypixel force-pushed the feature/investment-status-updates branch from 5afaede to 95da091 Compare August 7, 2017 19:40
@ztolley ztolley temporarily deployed to datahub-beta2-pr-424 August 7, 2017 19:40 Inactive
@tyom
Copy link
Contributor

tyom commented Aug 8, 2017

I wonder if we can use meta-item for this. We use it in investment project list items.

@@ -14,28 +13,18 @@
#}

{% if projectCode %}
<div class="status-bar grid-row">
<dl class="status-bar__section column-one-quarter">
<div class="l-container">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this class is causing some unnecessary spacing on smaller resolutions:

image

padding-left: ($gutter / 2) + (($gutter / 3) * 2);
}
}

dt {
Copy link
Contributor

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.

@ztolley ztolley temporarily deployed to datahub-beta2-pr-424 August 9, 2017 11:27 Inactive
@feedmypixel
Copy link
Contributor Author

feedmypixel commented Aug 9, 2017

I have updated this component to use the c-meta-item styles as suggested by @tyom and @teneightfive

screen shot 2017-08-09 at 12 23 59

@feedmypixel feedmypixel force-pushed the feature/investment-status-updates branch from 4cb4a43 to cf9c335 Compare August 9, 2017 11:30
@ztolley ztolley temporarily deployed to datahub-beta2-pr-424 August 9, 2017 11:30 Inactive
<dl>
{% for meta in props.meta %}
{% if meta.value %}
<div class="c-meta-item">
Copy link
Contributor

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/sibling/child

Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor

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.

@feedmypixel feedmypixel force-pushed the feature/investment-project-stages branch from 6f379b6 to e7d260a Compare August 9, 2017 14:05
@@ -6,16 +6,20 @@
+ &:nth-child(even) {
margin-left: $baseline-grid-unit;
}

& + & {
margin-left: $default-spacing-unit;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to affect it's current use on investment projects collection:

image

}

.c-meta-item__value {
color: $text-colour;
color: $grey-1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also changes how it previously looked on investment projects:

Before

image

After

image

# Render Meta fields for Investment
# @param {object[]} props.meta - Array of meta objects
#}
{% macro InvestmentMeta (props) %}
Copy link
Contributor

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)?

@feedmypixel feedmypixel force-pushed the feature/investment-project-stages branch from e7d260a to 2d12ba8 Compare August 9, 2017 14:38
@feedmypixel feedmypixel force-pushed the feature/investment-status-updates branch from cf9c335 to 3fd2686 Compare August 9, 2017 14:39
@ztolley ztolley temporarily deployed to datahub-beta2-pr-424 August 9, 2017 14:39 Inactive
@ztolley ztolley temporarily deployed to datahub-beta2-pr-424 August 9, 2017 15:40 Inactive
@ztolley ztolley temporarily deployed to datahub-beta2-pr-424 August 9, 2017 15:47 Inactive
@feedmypixel
Copy link
Contributor Author

@tyom @teneightfive updates up for this
screen shot 2017-08-09 at 16 45 51

@import "../settings";

.c-meta-bar {
margin-top: $default-spacing-unit;
Copy link
Contributor

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 %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this used here?

Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor Author

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({
Copy link
Contributor

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.

Copy link
Contributor Author

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 divs and it felt like there was a need for a dl here. Hence the creation of Meta component.

Copy link
Contributor

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.

#}
{% macro Meta(props) %}
{% if props.meta | length %}
<dl class="c-meta-bar">
Copy link
Contributor

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?

Copy link
Contributor Author

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

@feedmypixel feedmypixel force-pushed the feature/investment-project-stages branch from 6991049 to be30239 Compare August 9, 2017 21:26
@feedmypixel feedmypixel force-pushed the feature/investment-status-updates branch from 459efea to 7db4867 Compare August 9, 2017 21:27
@ztolley ztolley temporarily deployed to datahub-beta2-pr-424 August 9, 2017 21:27 Inactive
@ztolley ztolley temporarily deployed to datahub-beta2-pr-424 August 10, 2017 06:13 Inactive
@feedmypixel feedmypixel force-pushed the feature/investment-project-stages branch from be30239 to c7cf278 Compare August 10, 2017 08:38
@feedmypixel feedmypixel force-pushed the feature/investment-status-updates branch from 1af823a to e853641 Compare August 10, 2017 08:40
@ztolley ztolley temporarily deployed to datahub-beta2-pr-424 August 10, 2017 08:40 Inactive
@feedmypixel feedmypixel force-pushed the feature/investment-project-stages branch from c7cf278 to 260c8a1 Compare August 10, 2017 09:08
@feedmypixel feedmypixel force-pushed the feature/investment-status-updates branch from e853641 to 93b7cab Compare August 10, 2017 09:08
@ztolley ztolley temporarily deployed to datahub-beta2-pr-424 August 10, 2017 09:08 Inactive
@import "../settings";

.c-meta-list {
margin-top: $default-spacing-unit;
Copy link
Contributor

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;
Copy link
Contributor

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: [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

items?

<dl class="c-meta-list">
{% for meta in props.meta %}
{% if meta.value %}
<div class="c-meta-item">
Copy link
Contributor

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>?

Copy link
Contributor

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).

Copy link
Contributor Author

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

@ztolley ztolley temporarily deployed to datahub-beta2-pr-424 August 10, 2017 13:08 Inactive
@feedmypixel feedmypixel force-pushed the feature/investment-project-stages branch from 260c8a1 to 662195d Compare August 10, 2017 13:19
@feedmypixel feedmypixel force-pushed the feature/investment-status-updates branch from d1238e8 to 3e22c0e Compare August 10, 2017 13:24
@ztolley ztolley temporarily deployed to datahub-beta2-pr-424 August 10, 2017 13:25 Inactive
@feedmypixel feedmypixel force-pushed the feature/investment-status-updates branch from 3e22c0e to addf027 Compare August 10, 2017 13:31
@feedmypixel feedmypixel merged this pull request into feature/investment-project-stages Aug 10, 2017
@teneightfive teneightfive deleted the feature/investment-status-updates branch August 14, 2017 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants