@financial-times/n-myft-ui 31.0.1 → 31.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,6 +9,13 @@ const renderError = ({ message, preferencesModal }) => {
9
9
  errorElement.innerHTML = message;
10
10
  };
11
11
 
12
+ const removeError = ({ preferencesModal }) => {
13
+ renderError({
14
+ message: "",
15
+ preferencesModal,
16
+ });
17
+ }
18
+
12
19
  /**
13
20
  * This preference modal is part of a test
14
21
  * Therefore we have built the positioning function to work within the known parameters of that test
@@ -78,6 +85,7 @@ const tracking = (conceptId) => {
78
85
  const preferenceModalHide = ({ event, preferencesModal }) => {
79
86
  if (!preferencesModal.contains(event.detail.targetElement)) {
80
87
  preferencesModal.classList.remove('n-myft-ui__preferences-modal--show');
88
+ removeError({ preferencesModal });
81
89
  }
82
90
  };
83
91
 
@@ -91,23 +99,25 @@ const preferenceModalShowAndHide = ({ event, preferencesModal, conceptId }) => {
91
99
 
92
100
  } else {
93
101
  // Remove existing errors when hiding the modal
94
- renderError({
95
- message: '',
96
- preferencesModal,
97
- });
102
+ removeError({ preferencesModal });
98
103
  }
99
104
  };
100
105
 
101
106
  const removeTopic = async ({ event, conceptId, preferencesModal }) => {
102
107
  event.target.setAttribute('disabled', true);
103
108
 
109
+ // remove error message before attempt to remove topic
110
+ removeError({ preferencesModal });
111
+
104
112
  try {
105
113
  await myFtClient.remove('user', null, 'followed', 'concept', conceptId, { token: csrfToken });
106
114
  preferenceModalShowAndHide({ preferencesModal });
107
115
  } catch (error) {
108
- renderError({ message: 'Sorry, we are unable to remove this topic. Please try again later or try from <a href="/myft">myFT</a>', preferencesModal });
116
+ renderError({
117
+ message: 'Sorry, we are unable to remove this topic. Please try again later or try from <a href="/myft">myFT</a>',
118
+ preferencesModal,
119
+ });
109
120
  }
110
-
111
121
  event.target.removeAttribute('disabled');
112
122
  };
113
123
 
@@ -175,6 +185,9 @@ const toggleInstantAlertsPreference = async ({ event, conceptId, preferencesModa
175
185
 
176
186
  instantAlertsCheckbox.setAttribute('disabled', true);
177
187
 
188
+ // remove error message before attempt to toggle instant alert
189
+ removeError({ preferencesModal });
190
+
178
191
  const data = {
179
192
  token: csrfToken
180
193
  };
@@ -194,7 +207,7 @@ const toggleInstantAlertsPreference = async ({ event, conceptId, preferencesModa
194
207
  } catch (error) {
195
208
  renderError({
196
209
  message: 'Sorry, we are unable to change your instant alert preference. Please try again later or try from <a href="/myft">myFT</a>',
197
- preferencesModal
210
+ preferencesModal,
198
211
  });
199
212
 
200
213
  instantAlertsCheckbox.checked = instantAlertsCheckbox.checked
@@ -47,14 +47,39 @@
47
47
  color: oColorsByName('claret-60');
48
48
  }
49
49
 
50
+ .n-myft-ui__preferences-modal__remove-button:disabled {
51
+ opacity: 0.5;
52
+ }
53
+
50
54
  .n-myft-ui__preferences-modal--show {
51
55
  display: block;
52
56
  visibility: visible;
53
57
  }
54
58
 
59
+ // reference to the color/BG color of the error message
60
+ // components/o-message/src/scss/_brand.scss#L21 in origami
55
61
  .n-myft-ui__preferences-modal-error {
56
62
  display: block;
57
63
  @include oTypographySans($scale: -1, $weight: 'regular', $style: 'normal');
58
- color: oColorsByName('claret');
59
- text-align: center;
64
+ color: oColorsMix('black', 'crimson', $percentage: 12.5);
65
+ background-color: oColorsMix('crimson', $percentage: 10);
66
+ text-align: left;
67
+ padding: 8px 12px;
68
+ margin-top: 16px;
69
+
70
+ // use opacity to enforce CSS transition
71
+ opacity: 1;
72
+ transition: opacity 0.5s;
73
+
74
+ a {
75
+ @include oTypographySans($scale: -1, $weight: 'semibold', $style: 'normal');
76
+ color: oColorsMix('black', 'crimson', $percentage: 12.5);
77
+ text-decoration-color: oColorsMix('black', 'crimson', $percentage: 12.5);
78
+ }
79
+ }
80
+
81
+ .n-myft-ui__preferences-modal-error:empty {
82
+ opacity: 0;
83
+ padding: 0;
84
+ margin-top: 0;
60
85
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@financial-times/n-myft-ui",
3
- "version": "31.0.1",
3
+ "version": "31.0.2",
4
4
  "description": "Client side component for interaction with myft",
5
5
  "main": "server.js",
6
6
  "scripts": {