Commit Graph

654 Commits

Author SHA1 Message Date
Tom Byers
a9933010dc Merge pull request #2761 from alphagov/fix-sticky-stopping-bug
Fix bug which makes the sticky controls snap to the top of its scroll area
2019-02-13 16:08:31 +00:00
Chris Hill-Scott
77aba35c49 Add an ‘add logo’ button
Because some people don’t know they can put their own logo on letters:

> The HM Government Logo is at the top of the letter and we can't see
> a way of putting the [organisation] logo on

> We are intending to use the letter template feature for the first time
> and wondered whether the branding is configurable or whether the HM
> Government header is the standard default.

> Can we replace HM Government logo with our own in the letter? IF yes,
> then how?

> I don't seem to be able to set the branding on the letters to be
> [organisation]. it's always HM government. Is there something that
> needs enabling for this account?

No-one actually wants the HM Government logo (no-one is sending real
letters using it). So we should leave the space blank and put a button
there prompting people to add their own logo.
2019-02-13 15:12:36 +00:00
Tom Byers
994c9397fe Fix the logic handling spacing between stickys 2019-02-13 14:49:42 +00:00
Chris Hill-Scott
f9f8b6e99c Merge pull request #2750 from alphagov/embiggen-all-the-things
Embiggen all the things
2019-02-13 14:45:57 +00:00
Chris Hill-Scott
f2604494f0 Fix hover colour for ‘Switch service’ link 2019-02-13 13:32:31 +00:00
Chris Hill-Scott
1e82b6f8b3 Use pseudo elements not borders
This is the technique that GOV.UK Frontend uses to make clickable areas
of buttons bigger.

See: 47407edcb5/src/components/button/_button.scss (L89)
2019-02-13 13:28:32 +00:00
Tom Byers
30844143ec Fix bugs around operations happening between modes
The `release` method is meant to clean up a sticky
element before removal from the store.

The part of this that cleared CSS added due to
being in dialog mode was only run if still in that
mode.

In the template folder JS, we set the mode before
running `recalculate` so elements can be cleaned
in a different mode to that they were last in.
This meant some CSS wasn't being cleaned up.

This sometimes caused an effect where elements
that were added back to the DOM but not stuck
would still have CSS used when they were last
stuck.

This commit also includes the addition of some
missing code that adds back CSS to offset an
element when in a dialog stack.
2019-02-11 17:50:47 +00:00
Tom Byers
09848009c1 Correct reference to 'self' variable
It doesn't exist in this scope so the 'self' in
the scope above was being referenced instead,
preventing it from erroring.
2019-02-11 16:10:29 +00:00
Tom Byers
4c477d08a6 Put shift in focus after change to state
Moving focus before letting the sticky JS set the
position of sticky elements means focus is shifted
to them when they are still in the page. This
causes the browser to scroll so the focused
elements are visible.

This moves when focus is set to after the sticky
JS has set position therefore avoiding the issue.
2019-02-11 15:24:09 +00:00
Tom Byers
693ddadbc4 Deal with focus state following cancelation
Follows pattern from dialogs whereby focus returns
to the button/link that fired the dialog when it
closes.
2019-02-11 15:24:09 +00:00
Tom Byers
d633bdbb6d Tidy up JS code for focusing & associated html
Makes sure the tabindex we add for focusing is
removed.

Also removes the outer fieldset from the radios
for new templates. We don't wrap form buttons in
fieldsets anywhere else and it doesn't add any
useful semantics to the form.
2019-02-11 15:24:09 +00:00
Tom Byers
2b2641b039 Use JS for applying focus & add styling for it
Adds some extra styles so <fieldset>'s show as
focused when they are.

Also includes replacement of `overflow: hidden` on
sticky elements with a clearfix. hiding overflow
clips the outline and the clearfix can be used for
containing any floats instead. (I'm assuming that's
why it was set here.)
2019-02-11 15:24:09 +00:00
Chris Hill-Scott
1f2cb07deb Make hit area bigger on settings ‘change’ links
Bigger hit areas are generally better (cf Fitt’s law[1]), as long as
they’re not ambiguous.

This commit enlarges the hit area of the edit links (using a border) so
they fill the same vertical space as the smallest possible row (going
to the full height might look weird because some of these rows get very
tall).
2019-02-11 13:12:34 +00:00
Chris Hill-Scott
1117984f5a Make hit area bigger on team members ‘edit’ links
Bigger hit areas are generally better (cf Fitt’s law[1]), as long as
they’re not ambiguous.

This commit enlarges the hit area of the edit links (using a border) so
they fill the same vertical space as the row they sit in.
2019-02-11 13:00:24 +00:00
Chris Hill-Scott
980fc249d8 Stop flicker when hovering postage on precompiled
We were removing the border to ‘unfold’ the corner of the page. This was
causing the size of the element to shrink.

This meant that it you hovered the bottom 1px of the element it would
cycle in and out of the hover state as fast as the browser could render
it.

This commit fixes that by making the border transparent, rather than
removing it.
2019-02-08 16:44:37 +00:00
Chris Hill-Scott
6824eeebf5 Allow people to see the full precompiled letter
Sometimes people print stuff under where we’re folding the letter. It’s
annoying to not be able to see it.

This commit adds a little detail where, once you’ve sent the letter
you can unfolds the corner to see what’s underneath.

It’s better that we do this for all letters for discoverability.
2019-02-07 16:19:13 +00:00
Chris Hill-Scott
bfdca62f2d Move ‘change postage’ link
So it aligns with how we’re displaying postage on the template.
2019-02-06 14:37:16 +00:00
Chris Hill-Scott
cd70355db8 Display postage everywhere we display a letter
To avoid the problem of having confusing defaults, the postage is now
set explicitly on every template.

Putting the postage ‘inside’ the letter template makes the interaction
for changing it consistent with how other parts of the template are
added.

Plus everyone loves skeumorphism.
2019-02-06 14:37:16 +00:00
Chris Hill-Scott
ab8244ec5d Move ‘edit’ contact block link button
The contact block fills from the bottom upwards. So if it only has a few
lines then the ‘Edit’ link button sits quite far away from where the
text appears in the letter. This commit moves the link button to bottom
align with the contact block, so it’s always in close visual proximity.
2019-02-06 14:37:15 +00:00
Chris Hill-Scott
e0d28cf1dd Fix hover folder icon in IE10/11
Duplicates e0ecc95ac6

Copies the code from the normal folder icon, and manually tweaks the
colour, to also get the benefits of minification.

***

IE 10 supports using SVG[1] but has some buggy behaviour when they’re
used as background images.

Without an explicit width/height it stretches the viewBox of the SVG to
fill the containing element. This causes the content of the file to
display centered within the viewBox.

Explicitly setting the width and height seems to be the thing that fixes
this. Out of the suggested fixes on Stackoverflow[2] this one seems to
be the most straightforward.

1. https://caniuse.com/#feat=svg
2. https://stackoverflow.com/questions/17944354/svg-background-image-position-is-always-centered-in-internet-explorer-despite-b
2019-02-05 13:50:39 +00:00
Tom Byers
04ca620f46 Merge pull request #2726 from alphagov/fix-incorrect-use-of-inarray
$.inArray returns the same value as Array.indexOf
2019-02-04 15:23:40 +00:00
Chris Hill-Scott
ca6529dcdb Update app/assets/javascripts/templateFolderForm.js
Use native `Array.indexOf` instead.

Co-Authored-By: tombye <tombaromba@gmail.com>
2019-02-04 15:17:27 +00:00
Tom Byers
0e55521d8f $.inArray returns the same value as Array.indexOf 2019-02-04 14:56:18 +00:00
Pea Tyczynska
e85678fa69 Add link to edit postage to view_template page 2019-02-04 14:45:33 +00:00
Tom Byers
7ef32a6bd9 Replace native Array.includes with jQuery version
This was failing with a 'Object doesn't have
method' error on IE11. Assume Babel wasn't
polyfilling Array.includes so reverting to jQuery
version for now.
2019-02-04 11:23:41 +00:00
Chris Hill-Scott
6b02775927 Merge pull request #2718 from alphagov/sticky-footer-new-buttons
Add sticky footer on letter contact details, fix issues
2019-02-01 16:11:28 +00:00
Chris Hill-Scott
5597e63d44 Recalculate stickyness after API keys have rendered 2019-02-01 15:45:38 +00:00
Chris Hill-Scott
7632e6b9d3 Merge pull request #2717 from alphagov/sticky-footer-new-buttons
Make ‘Add new’ buttons sticky on more pages
2019-02-01 15:27:09 +00:00
Chris Hill-Scott
afdc749e36 Make ‘Add new’ buttons sticky on more pages
For consistency with the template management page.
2019-02-01 14:25:35 +00:00
Chris Hill-Scott
93df30d2df Normalise spacing of template breadcrumb heading
Removes the magic numbers, makes it visually look like it’s in the same
position as the 36px type size headings.
2019-02-01 12:22:36 +00:00
Chris Hill-Scott
e0d1f8e8ff Wrap, don’t truncate display of folder name in H1
This commit applies a carefully selected blend of `white-space`,
`display` and `background-position` to ensure that:
- you can always see the full name of the current folder in the heading
  (which is useful because people might have mutiple folders with the
  same name, differentiated by some king of suffix)
- the clickable are of a single folder or template in the list is 100%
  width, for the biggest possible hit area
- the name of a folder or template wraps underneath the folder icon (ie
  the folder icon is treated like a normal character, not like a bullet
  point)
2019-02-01 10:40:30 +00:00
Chris Hill-Scott
bba22b056f Remove unused assets 2019-02-01 10:28:29 +00:00
Chris Hill-Scott
88ad982bf7 Improve display of folder path when deeply nested
It’s a bit rudimentary to only show the current place in the hierarchy
and the parent. You lose a sense of how deep you are.

But we can’t just show the full path, because it can be arbitrarily
long. So what this commit does is show the full path, but truncates the
display of any items. Further-up than the current folder or its parent.

This also helps disambiguate between folders and templates, because
folders are always shown with the folder icon.

This probably won’t affect many teams, because we don’t anticipate a lot
of deep nesting.
2019-02-01 10:28:29 +00:00
Tom Byers
fd3ca31e44 Add adjustment for padding missed from previous
The work done to stack sticky elements closer
together only effected the stack when stuck to the
top/bottom edge:

707c426b9a

It should have included the same for when a stack
of sticky elements is stopped at the end of it's
scroll area. This adds code to deal with that.
2019-01-31 15:56:16 +00:00
Tom Byers
c89ad9635b Fix switch between modes and scrolling on adjust
The templateFolderForm JS was setting the mode to
'dialog' but not back when the state was changed
back to a normal sticky element. This caused
adjustments and scrolling when no adjustment
needed to be accommodated.

There were also problems with adjustForResize. It
was manipulating the same flag that resizing the
window did and returned a value never used.
2019-01-30 19:12:14 +00:00
Tom Byers
707c426b9a Remove padding between stickys when stacked 2019-01-30 14:59:30 +00:00
Tom Byers
f4d9c37940 Move setting of sticky mode out of recalculate
The `recalculate` method currently does three
things:
1. sync's the internal store with the DOM
2. updates the saved positional and dimensional
data from the new DOM
3. allows the mode to be set

The problem with using it as the way to set the
mode is that, every call to it is effectively
setting the mode but this isn't always the
intention.

This splits off setting the mode so other modules
have to explicity set it and those that don't
intend to can just call `recalculate` to notify of
DOM changes.
2019-01-30 11:45:24 +00:00
Tom Byers
177f30248e Fix bug with DOM sync'ing
If a sticky element was already in the store, the
code for adding it would return early. This meant
dimensions and positions for it were not being
recalculated.
2019-01-30 11:35:31 +00:00
Chris Hill-Scott
7f202b026f Fix jumpy right position of selected items counter
The negative right margin counteracts the sticky footer being wider than
its containing column. This is only the case when it’s actually sticky.
2019-01-29 09:30:06 +00:00
Leo Hemsted
d5e95af446 make classes in folder dialog states consistent
make sure the class is applied to a child element, so that `$el.find`
will always find something for `js-will-stick-at-bottom-when-scrolling`.

Also, clean up code by treating all stickies on the template folder
form as dialogs - they all are after all all dialogs - modals that
expect your attention on top of the main page content.
2019-01-25 16:47:49 +00:00
Tom Byers
05c455250c Fix calculation of in-page position
When the screen resizes, the dimensions of our
elements may change so we run
`setElementDimensions` again to update our store
of those values.

This caused a bug with the stored position of
stuck elements. When stuck, elements are
'fixed' so their position is relative to the
window position. We need the value stored to be
from the position in the document flow, not the
'fixed' value.

This change means, when an element is stuck, we
check its shim for the position instead. The shim
occupies the space the element would do in the
page so it makes sense to use it for this.
2019-01-23 16:55:18 +00:00
Tom Byers
59b02e0fe0 Change when folder controls become sticky
The controls for the template folders are all
present in the page when it loads. The
templateFolderForm JS filters them so you only see
the one you need to for the thing you're trying to
do.

This changes when the controls are made sticky so
it happens after the templateFolderForm JS has
performed its filtering.
2019-01-23 16:55:18 +00:00
Tom Byers
98789c98c8 Reset onload flag when recalculate called
This ensures sticky elements don't fade in if
in a sticky position when the page loads.

The fade is there to show when an element is
becoming sticky. This has no use if it was already
sticky the first time you see it.

Because the same situation applies when
recalculate is called, we also want the flag to be
reset before this happens.
2019-01-23 16:55:18 +00:00
Tom Byers
a9b7a0d887 Add box shadow by JS
When mode === 'dialog', sticky elements are
stacked so we need to apply the box shadow to the
top (when sticking to the bottom edge) and bottom
(when sticking to the top edge) elements in the
stack.

From what I can see, we need the version of
`nth-child` that supports targeting by selector.
As of this date, support for this is only in
Safari:

https://caniuse.com/#feat=css-nth-child-of

Until we can use this version of `nth-child`, we
need to use JS to apply the styles.
2019-01-23 16:55:18 +00:00
Tom Byers
4e845c3125 Move setting of events into separate method 2019-01-23 16:55:18 +00:00
Tom Byers
1e8e8908ee Move sync'ing this._els with DOM into own method
We'll need to run this whenever recalculate runs
to ensure `this._els` matches the present state of
the DOM.
2019-01-23 16:55:18 +00:00
Tom Byers
a6a7057d64 Deal with elements no longer in the DOM
Instead of keeping references to nodes detached
from the DOM, remove them from the store.
Likewise, add node appended to the DOM.

This includes code to 'clean' DOM nodes when
removed. This is important because nodes can
retain classes and styles. If they are re-attached
in future this can cause problems with how the
state of the element is determined.
2019-01-23 16:55:18 +00:00
Tom Byers
03e38dfdef Add mode for grouping sticky elements as a dialog
We want a mode for when a single task is shared
between all sticky elements on the page and that
task has the highest priority on the page. In that
case:
- they should stack together into a single block,
  attached to the top/bottom of the viewport
- that block should adjust to the vertical space
  available

This should also adjust to the height of the
viewport, dropping whatever elements that don't
fit back into the page flow. When this happens, we
scroll the page so all the parts of the dialog are
seen together at the start of the task.
2019-01-23 16:55:12 +00:00
Tom Byers
ea675f45da Make the sticky states more robust
If the screen resizes, sticky elements can end up
moving from one part of the screen to another,
sometimes without passing through their different
states (in-page, stuck, stopped) in the normal
order.

This makes the methods that change their states
better at dealing with those state changes.
2019-01-23 16:33:32 +00:00
Tom Byers
c0706b9cef Split move_to forms into separate sticky elements 2019-01-23 15:30:28 +00:00