This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {describe, it, expect} from 'vitest'; | |
import {merge} from './deepMerge'; | |
describe('deepMerge', () => { | |
it('should merge flat objects', () => { | |
const obj1 = {a: 1, b: 2}; | |
const obj2 = {c: 3, d: 4}; | |
const result = merge({}, obj1, obj2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Check out https://shopify.dev/docs/storefronts/headless/hydrogen/caching/full-page-cache for more information | |
import {CacheCustom, generateCacheControlHeader} from '@shopify/hydrogen'; | |
const fullPageCache = CacheCustom({ | |
mode: 'public', | |
maxAge: 60, | |
staleWhileRevalidate: 86400, | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { renderHook } from '@testing-library/react-hooks'; | |
import stateFactory from 'jest/stateFactory'; | |
import configureMockStore from 'redux-mock-store'; | |
import { Provider } from 'react-redux'; | |
import { Store, AnyAction } from 'redux'; | |
import { initialState as initialPaginationState } from '../../store/pagination/reducer'; | |
import { useMyAwesomeHook } from '../useMyAwesomeHook'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example: Forward env variables to the app (client-side) | |
module.exports = { | |
env: { | |
AN_ENV_VARIABLE: process.env.AN_ENV_VARIABLE, | |
}, | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* In a web component */ | |
// Private function to get the data from the "<script>" element | |
selectData = () => { | |
const options = this.slotContainerRef.querySelector('script'); | |
const optionsJSON = !!options && JSON.parse(options.innerHTML); | |
if (optionsJSON) { | |
return optionsJSON; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<my-navigation> | |
<script type="application/json" name="data"> | |
{ | |
"items": [ | |
{ "id": "home", "href": "/", "label": "Home" }, | |
{ "id": "about", "href": "/about", "label": "About" }, | |
] | |
} | |
</script> | |
</my-navigation> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import 'my-component-library/constants/_constants'; | |
@import 'my-component-library/constants/_mixins'; | |
.background { | |
background-color: $blue; // imported constant color | |
// imported mixin | |
@for-size($medium) { | |
background-color: $dark-blue; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ICONS } from "my-component-library/constants"; | |
// ... | |
render() { | |
return ( | |
<div> | |
<my-icon name={ICONS.ACCOUNT}></my-icon> | |
</div> | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<body> | |
<my-global-component reset></my-global-component> | |
<!-- rest of the page --> | |
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Writing this --> | |
<my-button theme="secondary">A button</my-button> | |
<!-- Actually renders this --> | |
<my-button theme="secondary"> | |
<button class="my-button my-button--secondary"> | |
<span class="label">A button</span> | |
</button> | |
</my-button> |
NewerOlder