-
Notifications
You must be signed in to change notification settings - Fork 75
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
Add support for labelGrid #7027
Conversation
innerGrid lets you adjust the size of form fields when the expected content is short. Here I provide a way to set labelGrid in order to enable long lists of short questions and answers to be presented in a table like way to save screen space.
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.
Neat! If you have a use case for this I see no reason not to support this grid prop. Agree @Febakke ?
The version defined in src/Altinn.Apps/AppFrontend/react/altinn-app-frontend/package.json
is used for versioning of the app-frontend application which is hosted at our cdn. This version should therefore be bumped.
We should also document this in a similar way as innerGrid. If ux agrees that this is something we want to go with.
Cool! 🔥 Why: |
I don't think it is possible to really ensure WCAG success with shorter labels. (without gridlines) A 6-6 split instead of 8-6 would probably be somewhat better in this example, but I changed it to have 1 fewer label with 2 lines of text. |
We can probably add something to the docs about long gaps that might lead to failing a WCAG success criteria. |
Theese are ignored in PartySelection as well, and are really annoying when they break altinn-studio\src\Altinn.Apps\AppFrontend\react\altinn-app-frontend> npm start
Then I have to admit Im a little sceptical of this solution. Label size should not be deciding if something is accessible or not. |
Regarding the risk that a combination of label sizes and split might make it possible to not meet all WCAG success criteria.
|
I think adding good docs and guidelines as suggested would make this a logical and simple expansion of our grid support. This is NICE! 👍 |
|
Great! I see more than one option for how to implement it in
It is nice to have some flexibility about where on the screen the split should be (sometimes the labels are long and answers are very short, and sometimes opposite.) |
@Febakke After some thinking I think I found out how to implement this, just adding the lines automatically under each field, based on the same breakpoints as specified in krt-.krt-1006-inkasso.-.Google.Chrome.2021-10-09.14-26-26_Trim_Trim.mp4PS: I used pure CSS because I don't know material very well, and we seem to be in the middle of a switch from 4-5 anyway. |
</Grid> | ||
</Grid> | ||
<hr className={gridToHiddenProps(props.grid?.labelGrid)} /> |
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 is the purpose of this hr?
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.
Gridline for users that might have issues figuring out what label is for which field🧑🦯
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.
OK, as you are using media-query anyway, could you maybe just style border on the Grid instead of adding more complexity to the DOM?
On line 47
, 59
and 241
is an example of how to use media-query and css with Mui.
This is the preferred method, as the library compiles the css classes with hashes and thereby preventing other components from accidentally get impacted.
@Febakke do you want the last element in the list to have a dotted line as well?
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 could definetly style
border-bottom
on theGrid
instead. I'm not sure what is best. - I started to use media queries with MUI, but there are quite extensive changes from MUI 4 to MUI 5, and https://github.com/Altinn/altinn-studio/issues/7047 indicates that making it work in MUI 4 is kind of wasted time.
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 think it would help to reduce the extra DOM elements.
- If one way over the other would remove the need to revisit the component when upgrading to MUI 5 I would go for that. I can't find where MUI 5 is going to stop supporting how we do media queries today.
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.
@mjulstein
Yes, it makes sense to me that all fields have a line at the bottom including the last one. You can see the sketch here: #7027 (comment)
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 was also curious about the extra line at the bottom of the last one, but I can't really see how to write a condition on the flow of the next item, so I think it is requried (unless we add some preprocessing).
@mjulstein I tried <Hidden
which will be gone, and sx
which is not availible yet. Pure jss will likely work, but I was tired after two failiures. Maybe the css->jss translation is simple. I'll try and report back.
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.
MUI is also changing its style library from styled-components
to emotion
, but reading that again, it seems like we will keep using the old way, so that is a much smaller issue than I thought.
@@ -291,4 +303,15 @@ const RenderLabelScoped = (props: IRenderLabelProps) => { | |||
); | |||
}; | |||
|
|||
const gridToHiddenProps = (props?: IGridStyling) => { | |||
return classNames({ |
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.
simplify this by checking props before every value. Can return props && ...
instead.
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'm not sure I understand. Can you elaborate?
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.
const gridToHiddenProps = (props?: IGridStyling) => {
return props && classNames({
hrLabelGrid: !!props,
xs: props.xs > 0 && props.xs < 12,
sm: props.sm > 0 && props.sm < 12,
md: props.md > 0 && props.md < 12,
lg: props.lg > 0 && props.lg < 12,
xl: props.xl > 0 && props.xl < 12,
});
};
There is no need to test props
on every line, and undefined
is better than empty string in className
as it should prevent lines that appear as <hr class />
to appear as <hr />
instead of a separate <hr> tag
@mjulstein I think all issues should be fixed now. Would you mind taking another look? |
@ivarne nice changes! Sorry that I didn't reply sooner. |
I think it is due to some secrets not available when I have a pull from a fork. |
https://docs.github.com/en/actions/managing-workflow-runs/approving-workflow-runs-from-public-forks @mjulstein Are you able to trigger a run manually? |
@mjulstein @ivarne so sorry for the long delay. I must have missed that I was tagged in anything here... Yeah, we need to manually run the cypress tests since we don't allow secrets on forks, we can do this when we are testing/confirming the change so that won't be a problem. @ivarne I assume this change is still something you still need? If we could resolve the merge conflict we could get our internal tester to take a look at this PR and hopefully get up to speed again. |
@lorang92 I think this branch is ok now. Just too bad I'm working on too many branches at once so I start working on making that a little easier, but then i just end up with 2 new branches. I'm a litte lost testing the finished merge, because of some unrelated build errors |
Thank you 👏 These build errors do seem to be related to our new lint rule setup (#7387), are you aware of any issues here @haakemon? |
Hm, thats odd... The error shouldnt appear for this. Ill have a look. |
regression test results for app frontend |
@jeevananthank @ivarne neat. Draggeg this issue to test now, @jeevananthank could you do a verification of the functionality described here Altinn/altinn-studio-docs#310 |
test is complete. |
@ivarne this is finally ready for merge. Would you mind merging with master and bump package.json? 👼 |
Done |
/AzurePipelines run |
You have several pipelines (over 10) configured to build pull requests in this repository. Specify which pipelines you would like to run by using /azp run [pipelines] command. You can specify multiple pipelines using a comma separated list. |
src/Altinn.Apps/AppFrontend/react/altinn-app-frontend/package.json
Outdated
Show resolved
Hide resolved
Could you look at Altinn/altinn-cdn#56 as well? |
* Added Json schema for labelGrid Altinn/altinn-studio#7027 * Update schemas/json/layout/layout.schema.v1.json Co-authored-by: Steffen Lorang Ekeberg <steffen.ekeberg@gmail.com> * Fix indentation levels in layout.schema.v1.json. Co-authored-by: Steffen Lorang Ekeberg <steffen.ekeberg@gmail.com>
* Added Json schema for labelGrid Altinn/altinn-studio#7027 * Update schemas/json/layout/layout.schema.v1.json Co-authored-by: Steffen Lorang Ekeberg <steffen.ekeberg@gmail.com> * Fix indentation levels in layout.schema.v1.json. Co-authored-by: Steffen Lorang Ekeberg <steffen.ekeberg@gmail.com>
innerGrid
lets you adjust the size of form fields when the expected content is short. Here I provide a way to setlabelGrid
in addition to enable long lists of short questions and answers to be presented in a table like way to save screen space.TODO
src/Altinn.Apps/AppFrontend/react/altinn-app-frontend/package.json
https://altinncdn.no/schemas/json/layout/layout.schema.v1.json
Added Json schema for labelGrid altinn-cdn#56Sample
krt-.krt-1006-inkasso.-.Google.Chrome.2021-10-01.13-17-28_Trim.mp4