Skip to content

Commit

Permalink
improved/simplified wrapping of button text for long button names on …
Browse files Browse the repository at this point in the history
…mobile
  • Loading branch information
twrichards committed Sep 9, 2019
1 parent 5855e08 commit 3de4285
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 21 deletions.
8 changes: 4 additions & 4 deletions app/client/__tests__/__snapshots__/main.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1016,9 +1016,9 @@ exports[`Main renders something 1`] = `
css={
Object {
"map": undefined,
"name": "3u56ol",
"name": "efdsqi",
"next": undefined,
"styles": "font-size:16px;font-family:\\"Guardian Text Sans Web\\", \\"Helvetica Neue\\", Helvetica, Arial, \\"Lucida Grande\\", sans-serif;border-radius:1000px;align-items:center;white-space:nowrap;position:relative;:active{outline:none;}min-height:36px;line-height:36px;font-weight:bold;display:inline-flex;background:#ffe500;color:#121212;border:none;padding:1px 40px 0 18px;svg{fill:currentColor;height:34px;position:absolute;right:0;top:50%;transform:translate(0, -50%);transition:transform .3s, background .3s;width:36px;}:hover{background:hsl(53.89999999999998, 100%, 45%);svg{transform:translate(3px, -50%);}}cursor:pointer;@media (max-width: 319px){max-width:280px;}@media (max-width: 424px){max-width:320px;white-space:normal;line-height:16px;}",
"styles": "font-size:16px;font-family:\\"Guardian Text Sans Web\\", \\"Helvetica Neue\\", Helvetica, Arial, \\"Lucida Grande\\", sans-serif;border-radius:1000px;align-items:center;position:relative;:active{outline:none;}min-height:36px;font-weight:bold;display:inline-flex;background:#ffe500;color:#121212;border:none;padding:1px 40px 0 18px;svg{fill:currentColor;height:34px;position:absolute;right:0;top:50%;transform:translate(0, -50%);transition:transform .3s, background .3s;width:36px;}:hover{background:hsl(53.89999999999998, 100%, 45%);svg{transform:translate(3px, -50%);}}cursor:pointer;max-width:calc(100vw - 40px);",
}
}
onMouseUp={[Function]}
Expand All @@ -1042,9 +1042,9 @@ exports[`Main renders something 1`] = `
css={
Object {
"map": undefined,
"name": "3u56ol",
"name": "efdsqi",
"next": undefined,
"styles": "font-size:16px;font-family:\\"Guardian Text Sans Web\\", \\"Helvetica Neue\\", Helvetica, Arial, \\"Lucida Grande\\", sans-serif;border-radius:1000px;align-items:center;white-space:nowrap;position:relative;:active{outline:none;}min-height:36px;line-height:36px;font-weight:bold;display:inline-flex;background:#ffe500;color:#121212;border:none;padding:1px 40px 0 18px;svg{fill:currentColor;height:34px;position:absolute;right:0;top:50%;transform:translate(0, -50%);transition:transform .3s, background .3s;width:36px;}:hover{background:hsl(53.89999999999998, 100%, 45%);svg{transform:translate(3px, -50%);}}cursor:pointer;@media (max-width: 319px){max-width:280px;}@media (max-width: 424px){max-width:320px;white-space:normal;line-height:16px;}",
"styles": "font-size:16px;font-family:\\"Guardian Text Sans Web\\", \\"Helvetica Neue\\", Helvetica, Arial, \\"Lucida Grande\\", sans-serif;border-radius:1000px;align-items:center;position:relative;:active{outline:none;}min-height:36px;font-weight:bold;display:inline-flex;background:#ffe500;color:#121212;border:none;padding:1px 40px 0 18px;svg{fill:currentColor;height:34px;position:absolute;right:0;top:50%;transform:translate(0, -50%);transition:transform .3s, background .3s;width:36px;}:hover{background:hsl(53.89999999999998, 100%, 45%);svg{transform:translate(3px, -50%);}}cursor:pointer;max-width:calc(100vw - 40px);",
}
}
onMouseUp={[Function]}
Expand Down
22 changes: 9 additions & 13 deletions app/client/components/buttons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Link } from "@reach/router";
import Color from "color";
import React from "react";
import palette from "../colours";
import { maxWidth } from "../styles/breakpoints";
import { sans } from "../styles/fonts";
import { ArrowIcon } from "./svgs/arrowIcon";
import { TickIcon } from "./svgs/tickIcon";
Expand All @@ -13,7 +12,6 @@ export interface ButtonProps {
onClick?: () => void;
height?: string;
fontWeight?: "bold";
maxWidthIfWrapping?: string;
left?: true;
right?: true;
disabled?: boolean;
Expand Down Expand Up @@ -90,7 +88,6 @@ const buttonCss = ({
disabled,
height,
fontWeight,
maxWidthIfWrapping,
colour = defaultColour,
textColour = palette.white,
left,
Expand All @@ -113,13 +110,11 @@ const buttonCss = ({
fontFamily: sans,
borderRadius: "1000px",
alignItems: "center",
whiteSpace: "nowrap",
position: "relative",
":active": {
outline: "none"
},
minHeight: height || "36px",
lineHeight: height || "36px",
fontWeight,
display: hide ? "none" : "inline-flex",
background: backgroundColour,
Expand All @@ -142,14 +137,15 @@ const buttonCss = ({
...applyIconStyleIfApplicable(true, left, right, leftTick)
},
cursor: disabled ? "not-allowed" : "pointer",
[maxWidth.mobile]: {
maxWidth: maxWidthIfWrapping || "280px"
},
[maxWidth.mobileLarge]: {
maxWidth: maxWidthIfWrapping || "320px",
whiteSpace: "normal",
lineHeight: "16px"
}
maxWidth: "calc(100vw - 40px)"
// [maxWidth.mobile]: {
// maxWidth: maxWidthIfWrapping || "280px"
// },
// [maxWidth.mobileLarge]: {
// maxWidth: maxWidthIfWrapping || "320px",
// whiteSpace: "normal",
// lineHeight: "16px"
// }
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ const getProductDetailSelector = (
props.productType.friendlyName
}
onClick={() => selectProductDetail(productDetail)}
maxWidthIfWrapping="290px"
right
primary
/>
Expand Down
2 changes: 0 additions & 2 deletions app/client/components/holiday/holidayConfirmed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,12 @@ export const HolidayConfirmed = (props: RouteableStepProps) => (
to={"/suspend/" + props.productType.urlPart + "/create"}
onClick={holidayStopsResponse.reload}
text="Schedule another suspension"
maxWidthIfWrapping="230px"
right
/>
<div css={{ width: "24px" }} />
<LinkButton
to={"/" + props.productType.urlPart}
text="Manage your subscriptions"
maxWidthIfWrapping="230px"
primary
right
/>
Expand Down
1 change: 0 additions & 1 deletion app/client/components/payment/update/paymentUpdated.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ const WithSubscriptionRenderer = (
<LinkButton
to={"/" + productType.urlPart}
text={"Manage your " + productType.friendlyName}
maxWidthIfWrapping="230px"
primary
right
/>
Expand Down

0 comments on commit 3de4285

Please sign in to comment.