Skip to content

Instantly share code, notes, and snippets.

@saumitra2810
saumitra2810 / page.wishlist.liquid
Last active May 4, 2023 18:16
Code for creating a custom wishlist page with Swym APIs for Shopify
<div class="page-width">
<div class="grid">
<div class="grid__item medium-up--five-sixths medium-up--push-one-twelfth">
<div class="section-header text-center">
<h1>{{ page.title }}</h1>
</div>
<div class="rte">
{{ page.content }}
</div>
var renderFunctions = [
function(item, rowIndex, offset){return offset + rowIndex + 1;},
function(item){
return <a target="_blank" href={item.a}>{item.b}</a>
},
function(item){return item.c}
];
var tableHeaders = ["S.No", "Header 1", "Header 2"];
var items = [{a: "X", b: "Y", c: "Z"}];
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import 'Table.css';
import { Card, Stack, Pagination, SkeletonDisplayText} from '@shopify/polaris';
export default class GeneralisedTable extends Component {
static propTypes = {
tableHeaders: PropTypes.array.isRequired, // array of header labels. Should be an array of strings
attributeRenderFunctions: PropTypes.array.isRequired, // array of render functions. function accepts an item from tableData, index of the item in the current page and the active offset (if pagination is enabled) as param and returns markup for that row
tableData: PropTypes.array.isRequired, // the actual data array
@saumitra2810
saumitra2810 / Hex ColorPicker using Shopify Polaris Colorpicker
Last active March 27, 2023 09:52
Wraps around Polaris colorpicker component with data exchange in HEX.
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import {Button, ColorPicker, TextField, Popover} from '@shopify/polaris';
import {hsbToHex, rgbToHsb} from '@shopify/polaris';
// interchange will always be hex
export default class HexColorPicker extends Component {
static propTypes = {
color: PropTypes.string,
; SOLUTION 1
(defn change-title-if-not-in-ignore-list [book changed-title ignore-list]
(let [in-ignore-list (some #(= (:serial-no book) %) ignore-list)]
(if (not in-ignore-list)
(assoc book :title changed-title)
book)))
(defn change-title [books changed-title ignore-list]
(let [books-vec (:books books)]
(->>