From c614beb9bfb8aabc19722b49a797b23986effb27 Mon Sep 17 00:00:00 2001 From: Andrew Leyva Date: Fri, 12 Oct 2018 19:13:20 -0700 Subject: [PATCH] feat(notification): more style updates, code refactors --- .../Notification-notification-menu-chrome.png | Bin 1810 -> 1874 bytes .../Notification/Notification.examples.md | 31 +++++------------- .../Notification/NotificationBody.jsx | 1 - .../Notification/NotificationHeader.jsx | 2 +- src/styles/components/notification.css | 8 +++-- src/styles/variables.css | 1 + 6 files changed, 15 insertions(+), 28 deletions(-) diff --git a/snaps/ref/Notification-notification-menu-chrome.png b/snaps/ref/Notification-notification-menu-chrome.png index 3b55804c3deda5d6d1e12001d9a59f0f31cc40bb..dc036e8054d1e2b661025f75b4eeb85880f8606f 100644 GIT binary patch literal 1874 zcmaJ?X*`?R9zLq2wpNSU+bO}+5Y(<*x3R|73I-#Vv5c##TwANL)2b@1Xc>EBLfTkr z(o5{6I*f#|#hMDeib@89prew^x!>-m`SSn0=lwnB|9{@+J4>Pw$Pg;6yA*DwQareP5eqh1I~jd7VIJG;_nFDT$E%jB>&p&s;T`&XaR4^x_0}y*|M%MC zH{~YSwjz&@+beWMc>#(EvD~>%tqtU904&4Zk3YJ;RK~~c^r+15 zTwL@(?X%?%xktO1sEo+O5-|XJq>IuGEG)~iJmT_(SlYns*&%|E0* z3@mLVq%D?H7RN~b5_(Di3_CMU&3D}1sv?ugjQM$sbsm!%%~|Tpa&mL~*3Rx8jZR;Q zF2!fVJZ7saNqzYwF?L#p_Jf&Q!r zg;+BZ-(B<4O!)fkV*pIPwhH2Mxh~mxTyFdngYkk$48>HlSOH$%-t`2+)%^T?8jXet z3tO@6q&|gtP?JT^C%=-Twam6s0N)P zZPzODsJQr?;(Y>x;Tg5qlQPY}MfJn&|6Yjj?@3O=ly4mj%9XSSvy9(`HH~pZPmSPI z0Pr#M6CUW#Ijw~j%2z4`m{3m5=cJ@aUVT{-cO=Z%(sLzSbHR{o!tn)+?A46iot($6!=g$`- zG+;O+4ezGBQ4v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*rT8vh{0OzGe3^=d7PY+pJKfSW>l8hU%Dy(Z0Ys-<6|6NyAmcXvxD^50Qv^>UxvIy&;UVqh>B z*48#(_=VO>HHXXgIdLqPYBjHD+bv|mq6;cT&3_nEc?f2Q;8uxrqJ6Me5|O-4iPiinu@ z9bsBLIRv5(@S+eq5;WmZKb1=gK_fbn_}#?Y2CaEK4YA3&HMmG lMOeoEs-UBTznNokAoMQr { - if (notification) { - console.log('clicked: '+notification) - console.log('READ: ' + notification.isMsgRead) - let notificationIdx = undefined - for (let i = 0; i < notifications.length; i++) { - console.log(notifications[i].id + ' =? ' + notification.id) - if (notifications[i].id === notification.id) { - notificationIdx = i; - break; - } - } + const clickedBack = (typeof notification == 'undefined') + if (!clickedBack) { + const notificationIdx = notifications.findIndex( (item) => { + return item.id === notification.id + }) notifications[notificationIdx].isMsgRead = true } - console.log('update notifs') - console.log(notifications) setState({ selectedNotification: notification, notifications: notifications}) } } onClearAll={() => { - console.log('Clear All') setState({ selectedNotification: undefined, notifications: []}) } } onClearNotification={notification => { - console.log('clear: ' + notification.id) - let notificationIdx = undefined - for (let i = 0; i < notifications.length; i++) { - console.log(notifications[i].id + ' =? ' + notification.id) - if (notifications[i].id === notification.id) { - notificationIdx = i; - break; - } - } + const notificationIdx = notifications.findIndex( (item) => { + return item.id === notification.id + }) delete notifications[notificationIdx] setState({ selectedNotification: undefined, notifications: notifications}) } diff --git a/src/components/Notification/NotificationBody.jsx b/src/components/Notification/NotificationBody.jsx index baf7a09..0b33a3d 100644 --- a/src/components/Notification/NotificationBody.jsx +++ b/src/components/Notification/NotificationBody.jsx @@ -29,7 +29,6 @@ const NotificationBody = props => { } if (notificationsLength > 0) { return notifications.map(notification => { - console.log(notification.id) return getNotification(notification, 'notificationList') }) } else { diff --git a/src/components/Notification/NotificationHeader.jsx b/src/components/Notification/NotificationHeader.jsx index 72e8ab4..cb62174 100644 --- a/src/components/Notification/NotificationHeader.jsx +++ b/src/components/Notification/NotificationHeader.jsx @@ -27,7 +27,7 @@ const NotificationHeader = props => { ) const listView = (
- {title} +

{title}

{notificationCount} {children}
diff --git a/src/styles/components/notification.css b/src/styles/components/notification.css index 5c4a8cc..6533fbe 100644 --- a/src/styles/components/notification.css +++ b/src/styles/components/notification.css @@ -55,10 +55,12 @@ } & .notificationHeader{ border-bottom:1px solid var(--gray); - padding: 12px 15px; + padding: var(--standardMargin); & .notificationTitle{ font-size:1.2em; font-weight: bold; + display: inline-block; + margin: 0; } & .notificationCount{ display: inline-block; @@ -96,7 +98,7 @@ overflow-y: auto; & .singleNotification{ cursor: pointer; - padding: 15px 8px 5px; + padding: var(--standardMargin) 8px var(--standardMargin); border-bottom: 1px solid var(--gray); &.active,&.unread{ background: var(--whisperGray); @@ -136,7 +138,7 @@ border-bottom: none; } & .detailView{ - padding:15px; + padding: var(--standardMargin); & .notificationContent{ padding-left:10px; & .notificationTitle{ diff --git a/src/styles/variables.css b/src/styles/variables.css index 4f80b6c..8de44ab 100644 --- a/src/styles/variables.css +++ b/src/styles/variables.css @@ -71,6 +71,7 @@ --small: 0.85rem; --semibold: 600; --subtitlesize: 14px; + --standardMargin: 15px; --base-border-radius: 0; }