site/lib/storage.js
Ella 89881fd7e8 Move /bank page to v3 (#167)
* initial migration

* port landing and feature components

* Features section

* Add event cards in Testimonials (no styles)

* add everything section

* everything but no styling

* fFix some styles in Everything.js

* Add Start section without the form yet

* Fix testimonials section grid

* Fix styles on Landing

* Styles on Everything section

* Fix testimonials cards

* Fix console error and testimonial cards

* Fix landing and style bugs

* Fix styles

* Add selection color

* Fix Grid on everything section

* Fetch transaction data from api

* Style stats

* Fix landing on mobile

* Fix some bugs and responsiveness

* Fix 🐛 so the form exists now

* Fix bugs & add timeline

* Fix Laptop in Grid

* Switch to Dark Laptop

* Fix Stat Text Size

* Form -> Airtable

* Change to hred to primary, align ModuleDetails card

* Remove dates

* Fix Event card to align items center

* Add mtop margin to transparency button

* Fix Run.js icon styles

* Make fiscal sponsor note more readable

* Add 2 tone colors btwn Start and Everything

* Flashing green dot

* Confusion

* Update components/bank/Timeline.js

Co-authored-by: Sam Poder <39828164+sampoder@users.noreply.github.com>

* Fix remaining style bugs

* small fix

* small fix

* Fix Form

* Fixes

- fix timeline horizontal
- green to hack club theme green
- more horizontal margin on everything section
- attempt to fix testimonial grid

* center 7 (percentage)

* Fix testimonial grid layout

* Fix landing

* Fix horizontal scroll on mobile

* Fix styles on event card

* Decrease font size and padding

* Actually fix it this time

* Fix styles

* Responsiveness and mobile styling

* Slight styles changes

* Fix Margins

* Neutralize

Co-authored-by: Sam Poder <39828164+sampoder@users.noreply.github.com>
2021-08-22 14:05:22 +08:00

33 lines
870 B
JavaScript

const stubbedStorage = {}
'get set remove keys'
.split(' ')
.forEach(method => (stubbedStorage[method] = () => null))
let localStorage
try {
localStorage = window.localStorage
} catch (e) {
if (e instanceof ReferenceError) {
localStorage = stubbedStorage
}
}
const storage = {
get: key => {
try {
// (max@maxwofford.com) Values that were set before values were stringified might fail to parse, so we return the raw storage item if we can't parse it
return JSON.parse(localStorage.getItem(key))
} catch (e) {
if (e.name === 'SyntaxError') {
return localStorage.getItem(key)
} else {
console.error(e)
}
}
},
set: (key, value) => localStorage.setItem(key, JSON.stringify(value)),
remove: key => localStorage.removeItem(key),
keys: () => Object.keys(localStorage)
}
export default storage