id
stringlengths 12
53
| messages
listlengths 3
3
|
|---|---|
code_store-on-localhost_d5415535
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/Failure/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 16,\n height: 16,\n}\n\nclass Failure extends PureComponent {\n render() {\n const { color, size, solid, block } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg\n name=\"failure\"\n variation={solid ? 'solid' : null}\n size={newSize}\n block={block}>\n {solid ? (\n <path\n d=\"M8 0C3.6 0 0 3.6 0 8C0 12.4 3.6 16 8 16C12.4 16 16 12.4 16 8C16 3.6 12.4 0 8 0ZM11.5 10.1L10.1 11.5L8 9.4L5.9 11.5L4.5 10.1L6.6 8L4.5 5.9L5.9 4.5L8 6.6L10.1 4.5L11.5 5.9L9.4 8L11.5 10.1Z\"\n fill={color}\n />\n ) : (\n <>\n <path\n d=\"M5.6 0L3.5 2.1L1.4 0L0 1.4L2.1 3.5L0 5.6L1.4 7L3.5 4.9L5.6 7L7 5.6L4.9 3.5L7 1.4L5.6 0Z\"\n transform=\"translate(4.5 4.5)\"\n fill={color}\n />\n <path\n d=\"M8 0C3.6 0 0 3.6 0 8C0 12.4 3.6 16 8 16C12.4 16 16 12.4 16 8C16 3.6 12.4 0 8 0ZM8 14C4.7 14 2 11.3 2 8C2 4.7 4.7 2 8 2C11.3 2 14 4.7 14 8C14 11.3 11.3 14 8 14Z\"\n fill={color}\n />\n </>\n )}\n </Svg>\n )\n }\n}\n\nFailure.defaultProps = {\n color: 'currentColor',\n size: 16,\n solid: false,\n block: false,\n}\n\nFailure.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n solid: PropTypes.bool,\n block: PropTypes.bool,\n}\n\nexport default Failure\n\n```"
}
] |
code_store-on-localhost_e18675d9
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/Download/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 14,\n height: 16,\n}\n\nclass Download extends PureComponent {\n render() {\n const { color, size, block } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg name=\"download\" size={newSize} block={block} viewBox=\"0 0 14 16\">\n <path\n d=\"M6.4 12C6.7 12 6.9 11.9 7.1 11.7L12.8 6L11.4 4.6L7.4 8.6V0H5.4V8.6L1.4 4.6L2.38419e-08 6L5.7 11.7C5.9 11.9 6.1 12 6.4 12Z\"\n transform=\"translate(0.599976)\"\n fill={color}\n />\n <path d=\"M14 0H0V2H14V0Z\" transform=\"translate(0 14)\" fill={color} />\n </Svg>\n )\n }\n}\n\nDownload.defaultProps = {\n color: 'currentColor',\n size: 16,\n block: false,\n}\n\nDownload.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n block: PropTypes.bool,\n}\n\nexport default Download\n\n```"
}
] |
code_store-on-localhost_8e16e85c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/CaretLeft/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 10,\n height: 14,\n}\n\nclass CaretLeft extends PureComponent {\n render() {\n const { color, size, block } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg name=\"caret-left\" size={newSize} block={block} viewBox=\"0 0 10 14\">\n <path\n d=\"M7.72356 8.48154C7.32958 8.89452 6.67042 8.89452 6.27644 8.48154L0 1.90235L1.81481 0L7 5.43529L12.1852 0L14 1.90235L7.72356 8.48154Z\"\n transform=\"translate(9.23999) rotate(90)\"\n fill={color}\n />\n </Svg>\n )\n }\n}\n\nCaretLeft.defaultProps = {\n color: 'currentColor',\n size: 16,\n block: false,\n}\n\nCaretLeft.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n block: PropTypes.bool,\n}\n\nexport default CaretLeft\n\n```"
}
] |
code_store-on-localhost_666784a3
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/Bold/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 18,\n height: 12,\n}\n\nclass Bold extends PureComponent {\n render() {\n const { color, size, block } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg\n name=\"bold\"\n size={newSize}\n block={block}\n viewBox=\"0 0 64 64\"\n fill={color}>\n <path\n fill={color}\n d=\"M43.06677,30.83765v-0.24634c5.05432-1.65662,10.10852-6.04956,10.10852-13.92456 C53.17529,8.4646,49.19739,2,35.02649,2H8v6l3.26491,1.0883C12.89828,9.63276,14,11.16131,14,12.88304v38.23392 c0,1.72172-1.10172,3.25028-2.73509,3.79473L8,56v6h26.28088c13.01013,0,22.62268-4.22766,22.62268-16.49219 C56.90356,37.22119,52.51404,31.91736,43.06677,30.83765z M26,10h7c4.97058,0,9,4.02942,9,9s-4.02942,9-9,9h-7V10z M35,54h-9V36h9 c4.97058,0,9,4.02942,9,9S39.97058,54,35,54z\"\n />\n </Svg>\n )\n }\n}\n\nBold.defaultProps = {\n color: 'currentColor',\n size: 20,\n block: false,\n}\n\nBold.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n block: PropTypes.bool,\n}\n\nexport default Bold\n\n```"
}
] |
code_store-on-localhost_5b686ff1
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/CaretRight/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 10,\n height: 14,\n}\n\nclass CaretRight extends PureComponent {\n render() {\n const { color, size, block } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg name=\"caret-right\" size={newSize} block={block} viewBox=\"0 0 10 14\">\n <path\n d=\"M7.72356 8.48154C7.32958 8.89452 6.67042 8.89452 6.27644 8.48154L0 1.90235L1.81481 0L7 5.43529L12.1852 0L14 1.90235L7.72356 8.48154Z\"\n transform=\"translate(0 14) rotate(-90)\"\n fill={color}\n />\n </Svg>\n )\n }\n}\n\nCaretRight.defaultProps = {\n color: 'currentColor',\n size: 16,\n block: false,\n}\n\nCaretRight.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n block: PropTypes.bool,\n}\n\nexport default CaretRight\n\n```"
}
] |
code_store-on-localhost_a5c03b86
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/ShoppingCart/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 44,\n height: 44,\n}\n\nclass ShoppingCart extends PureComponent {\n render() {\n const { color, size, block } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg\n name=\"shopping-cart\"\n size={newSize}\n block={block}\n viewBox=\"0 0 32 30\">\n <path\n d=\"M8 30C9.65685 30 11 28.6569 11 27C11 25.3431 9.65685 24 8 24C6.34315 24 5 25.3431 5 27C5 28.6569 6.34315 30 8 30Z\"\n fill={color}\n />\n <path\n d=\"M27 30C28.6569 30 30 28.6569 30 27C30 25.3431 28.6569 24 27 24C25.3431 24 24 25.3431 24 27C24 28.6569 25.3431 30 27 30Z\"\n fill={color}\n />\n <path\n d=\"M28 22H7C6.505 22 6.084 21.638 6.011 21.148L3.139 2H0V0H4C4.495 0 4.916 0.362 4.989 0.852L5.611 5H31C31.3 5 31.583 5.134 31.773 5.366C31.963 5.597 32.039 5.902 31.98 6.196L28.98 21.196C28.887 21.664 28.477 22 28 22Z\"\n fill={color}\n />\n </Svg>\n )\n }\n}\n\nShoppingCart.defaultProps = {\n color: 'currentColor',\n size: 20,\n block: false,\n}\n\nShoppingCart.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n block: PropTypes.bool,\n}\n\nexport default ShoppingCart\n\n```"
}
] |
code_store-on-localhost_1d4c3872
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/Copy/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 18,\n height: 18,\n}\n\nclass Copy extends PureComponent {\n render() {\n const { color, size, block } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg name=\"copy\" size={newSize} block={block} viewBox=\"0 0 18 18\">\n <path\n d=\"M6.4 0H9.2C10.3046 0 11.2 0.895431 11.2 2V9.2C11.2 10.3046 10.3046 11.2 9.2 11.2H2C0.89543 11.2 0 10.3046 0 9.2V6.4\"\n transform=\"translate(5.80005 12.2) rotate(-90)\"\n stroke={color}\n strokeWidth=\"2\"\n strokeMiterlimit=\"10\"\n strokeLinecap=\"square\"\n />\n <path\n d=\"M9.2 0H2C0.895431 0 0 0.89543 0 2V9.2C0 10.3046 0.89543 11.2 2 11.2H9.2C10.3046 11.2 11.2 10.3046 11.2 9.2V2C11.2 0.895431 10.3046 0 9.2 0Z\"\n transform=\"translate(1 17) rotate(-90)\"\n stroke={color}\n strokeWidth=\"2\"\n strokeMiterlimit=\"10\"\n strokeLinecap=\"square\"\n />\n </Svg>\n )\n }\n}\n\nCopy.defaultProps = {\n color: 'currentColor',\n size: 16,\n block: false,\n}\n\nCopy.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n block: PropTypes.bool,\n}\n\nexport default Copy\n\n```"
}
] |
code_store-on-localhost_a3b5873e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/ExternalLink/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 16,\n height: 16,\n}\n\nclass ExternalLink extends PureComponent {\n render() {\n const { color, size, block } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg name=\"external-link\" size={newSize} block={block}>\n <path\n d=\"M8.7 0H1.7V2H6.3L1.90735e-07 8.3L1.4 9.7L7.7 3.4V8H9.7V1C9.7 0.4 9.3 0 8.7 0Z\"\n transform=\"translate(6.30005)\"\n fill={color}\n />\n <path\n d=\"M14 15H1C0.4 15 0 14.6 0 14V1C0 0.4 0.4 0 1 0H5V2H2V13H13V10H15V14C15 14.6 14.6 15 14 15Z\"\n transform=\"translate(0 1)\"\n fill={color}\n />\n </Svg>\n )\n }\n}\n\nExternalLink.defaultProps = {\n color: 'currentColor',\n size: 16,\n block: false,\n}\n\nExternalLink.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n block: PropTypes.bool,\n}\n\nexport default ExternalLink\n\n```"
}
] |
code_store-on-localhost_f059e06d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/Text/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 18,\n height: 12,\n}\n\nclass Text extends PureComponent {\n render() {\n const { color, size, block } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg\n name=\"text\"\n size={newSize}\n block={block}\n viewBox=\"0 0 64 64\"\n fill={color}>\n <path\n fill={color}\n d=\"M58,2H6C5.448,2,5,2.448,5,3v12c0,0.552,0.448,1,1,1h2c0.265,0,0.52-0.105,0.707-0.293L14.414,10H27v42.586 l-5.707,5.707C21.105,58.48,21,58.735,21,59v2c0,0.552,0.448,1,1,1h20c0.552,0,1-0.448,1-1v-2c0-0.265-0.105-0.52-0.293-0.707 L37,52.586V10h12.465l3.703,5.555C53.354,15.833,53.666,16,54,16h4c0.552,0,1-0.448,1-1V3C59,2.448,58.552,2,58,2z\"\n />\n </Svg>\n )\n }\n}\n\nText.defaultProps = {\n color: 'currentColor',\n size: 20,\n block: false,\n}\n\nText.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n block: PropTypes.bool,\n}\n\nexport default Text\n\n```"
}
] |
code_store-on-localhost_1c2bd432
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/Columns/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBaseDimensions = {\n width: 16,\n height: 18,\n}\n\nclass Columns extends PureComponent {\n render() {\n const { color, size, block } = this.props\n const newSize = calcIconSize(iconBaseDimensions, size)\n return (\n <Svg name=\"columns\" size={newSize} block={block}>\n <path d=\"M1 4H15V15H1V4Z\" stroke={color} strokeWidth=\"2\" />\n <path\n d=\"M0 1C0 0.447715 0.447715 0 1 0H15C15.5523 0 16 0.447715 16 1V5H0V1Z\"\n fill={color}\n />\n <line\n x1=\"8.11133\"\n y1=\"4.70586\"\n x2=\"8.11133\"\n y2=\"14.1176\"\n stroke={color}\n strokeWidth=\"2\"\n />\n </Svg>\n )\n }\n}\n\nColumns.defaultProps = {\n color: 'currentColor',\n size: 16,\n block: false,\n}\n\nColumns.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n block: PropTypes.bool,\n}\n\nexport default Columns\n\n```"
}
] |
code_store-on-localhost_c76049dc
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/TableFilter/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 13,\n height: 12,\n}\n\nclass TableFilter extends PureComponent {\n render() {\n const { color, size, block } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg name=\"table-filter\" size={newSize} block={block} viewBox=\"0 0 13 12\">\n <path\n d=\"M10.7042 0H8.56339V2H6.42255V4H12.8451V2H10.7042V0Z\"\n fill={color}\n />\n <path d=\"M10.7042 5H8.56335V12H10.7042V5Z\" fill={color} />\n <path d=\"M0 10H2.14085V12H4.28169V10H6.42253V8H0V10Z\" fill={color} />\n <path d=\"M4.28171 0H2.14087V7H4.28171V0Z\" fill={color} />\n </Svg>\n )\n }\n}\n\nTableFilter.defaultProps = {\n color: 'currentColor',\n size: 16,\n block: false,\n}\n\nTableFilter.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n block: PropTypes.bool,\n}\n\nexport default TableFilter\n\n```"
}
] |
code_store-on-localhost_64494ac7
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/Filter/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nclass Filter extends PureComponent {\n render() {\n const { color, size, solid, block } = this.props\n const iconBase = {\n width: solid ? 16 : 18,\n height: solid ? 16 : 21,\n }\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg\n name=\"filter\"\n variation={solid ? 'solid' : null}\n size={newSize}\n block={block}\n viewBox={solid ? '0 0 16 18' : '0 0 18 21'}>\n {solid ? (\n <path\n d=\"M15 0H1C0.4 0 0 0.4 0 1V3C0 3.3 0.1 3.6 0.4 3.8L6 8.5V15C6 15.4 6.2 15.8 6.6 15.9C6.7 16 6.9 16 7 16C7.3 16 7.5 15.9 7.7 15.7L9.7 13.7C9.9 13.5 10 13.3 10 13V8.5L15.6 3.8C15.9 3.6 16 3.3 16 3V1C16 0.4 15.6 0 15 0Z\"\n fill={color}\n />\n ) : (\n <path\n d=\"M16 3.16441C16 3.45327 15.8751 3.72803 15.6574 3.91794L10.1204 8.74873C9.90269 8.93864 9.77778 9.21339 9.77778 9.50226V16.5773C9.77778 16.9536 9.56663 17.2979 9.23135 17.4686L7.67579 18.2602C7.0105 18.5988 6.22222 18.1155 6.22222 17.369V9.50226C6.22222 9.21339 6.09731 8.93864 5.87964 8.74873L0.342585 3.91794C0.124915 3.72803 0 3.45327 0 3.16441V1C0 0.447715 0.447715 0 1 0H15C15.5523 0 16 0.447715 16 1V3.16441Z\"\n transform=\"translate(1 1)\"\n stroke={color}\n strokeWidth=\"2\"\n strokeMiterlimit=\"10\"\n strokeLinecap=\"square\"\n />\n )}\n </Svg>\n )\n }\n}\n\nFilter.defaultProps = {\n color: 'currentColor',\n size: 16,\n solid: false,\n block: false,\n}\n\nFilter.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n solid: PropTypes.bool,\n block: PropTypes.bool,\n}\n\nexport default Filter\n\n```"
}
] |
code_store-on-localhost_aec21f59
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/Save/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 16,\n height: 16,\n}\n\nclass Save extends PureComponent {\n render() {\n const { color, size, block } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg name=\"save\" size={newSize} block={block}>\n <path\n d=\"M11.7 0.3C11.5 0.1 11.3 0 11 0H10V3C10 3.6 9.6 4 9 4H4C3.4 4 3 3.6 3 3V0H1C0.4 0 0 0.4 0 1V15C0 15.6 0.4 16 1 16H15C15.6 16 16 15.6 16 15V5C16 4.7 15.9 4.5 15.7 4.3L11.7 0.3ZM13 14H3V11C3 10.4 3.4 10 4 10H12C12.6 10 13 10.4 13 11V14Z\"\n fill={color}\n />\n <path d=\"M2 0H0V3H2V0Z\" transform=\"translate(7)\" fill={color} />\n </Svg>\n )\n }\n}\n\nSave.defaultProps = {\n color: 'currentColor',\n size: 16,\n block: false,\n}\n\nSave.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n block: PropTypes.bool,\n}\n\nexport default Save\n\n```"
}
] |
code_store-on-localhost_47ce8212
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/Check/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 12,\n height: 12,\n}\n\nclass Check extends PureComponent {\n render() {\n const { color, size, block } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg name=\"check\" size={newSize} block={block} viewBox=\"0 0 12 12\">\n <path\n d=\"M10.8 4.4L9.4 3L5.4 7L3.4 5L2 6.4L5.4 9.8L10.8 4.4Z\"\n fill={color}\n />\n </Svg>\n )\n }\n}\n\nCheck.defaultProps = {\n color: 'currentColor',\n size: 16,\n block: false,\n}\n\nCheck.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n block: PropTypes.bool,\n}\n\nexport default Check\n\n```"
}
] |
code_store-on-localhost_607aebb6
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/Help/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 16,\n height: 16,\n}\n\nclass Help extends PureComponent {\n render() {\n const { color, size, solid, block } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg\n name=\"help\"\n variation={solid ? 'solid' : null}\n size={newSize}\n block={block}>\n {solid ? (\n <path\n d=\"M8 0C3.6 0 0 3.6 0 8C0 12.4 3.6 16 8 16C12.4 16 16 12.4 16 8C16 3.6 12.4 0 8 0ZM8 13C7.4 13 7 12.6 7 12C7 11.4 7.4 11 8 11C8.6 11 9 11.4 9 12C9 12.6 8.6 13 8 13ZM9.5 8.4C9 8.7 9 8.8 9 9V10H7V9C7 7.7 7.8 7.1 8.4 6.7C8.9 6.4 9 6.3 9 6C9 5.4 8.6 5 8 5C7.6 5 7.3 5.2 7.1 5.5L6.6 6.4L4.9 5.4L5.4 4.5C5.9 3.6 6.9 3 8 3C9.7 3 11 4.3 11 6C11 7.4 10.1 8 9.5 8.4Z\"\n fill={color}\n />\n ) : (\n <>\n <path\n d=\"M8 0C3.6 0 0 3.6 0 8C0 12.4 3.6 16 8 16C12.4 16 16 12.4 16 8C16 3.6 12.4 0 8 0ZM8 14C4.7 14 2 11.3 2 8C2 4.7 4.7 2 8 2C11.3 2 14 4.7 14 8C14 11.3 11.3 14 8 14Z\"\n fill={color}\n />\n <path\n d=\"M1 2C1.55228 2 2 1.55228 2 1C2 0.447715 1.55228 0 1 0C0.447715 0 0 0.447715 0 1C0 1.55228 0.447715 2 1 2Z\"\n transform=\"translate(7 11)\"\n fill={color}\n />\n <path\n d=\"M2.2 2.5C2.4 2.2 2.7 2 3.1 2C3.7 2 4.1 2.4 4.1 3C4.1 3.3 4 3.4 3.5 3.7C2.9 4.1 2.1 4.7 2.1 6V7H4.1V6C4.1 5.8 4.1 5.7 4.6 5.4C5.2 5 6.1 4.4 6.1 3C6.1 1.3 4.8 0 3.1 0C2 0 1 0.6 0.5 1.5L9.53674e-08 2.4L1.7 3.4L2.2 2.5Z\"\n transform=\"translate(4.90002 3)\"\n fill={color}\n />\n </>\n )}\n </Svg>\n )\n }\n}\n\nHelp.defaultProps = {\n color: 'currentColor',\n size: 16,\n solid: false,\n block: false,\n}\n\nHelp.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n solid: PropTypes.bool,\n block: PropTypes.bool,\n}\n\nexport default Help\n\n```"
}
] |
code_store-on-localhost_35b0f4ae
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/Clock/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 16,\n height: 16,\n}\n\nclass Clock extends PureComponent {\n render() {\n const { color, size, block } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg name=\"clock\" size={newSize} block={block}>\n <path\n d=\"M8 0C3.6 0 0 3.6 0 8C0 12.4 3.6 16 8 16C12.4 16 16 12.4 16 8C16 3.6 12.4 0 8 0ZM8 14C4.7 14 2 11.3 2 8C2 4.7 4.7 2 8 2C11.3 2 14 4.7 14 8C14 11.3 11.3 14 8 14Z\"\n fill={color}\n />\n <path d=\"M2 0H0V5H5V3H2V0Z\" transform=\"translate(7 4)\" fill={color} />\n </Svg>\n )\n }\n}\n\nClock.defaultProps = {\n color: 'currentColor',\n size: 16,\n block: false,\n}\n\nClock.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n block: PropTypes.bool,\n}\n\nexport default Clock\n\n```"
}
] |
code_store-on-localhost_ea69ccdc
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/Upload/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 14,\n height: 16,\n}\n\nclass Upload extends PureComponent {\n render() {\n const { color, size, block } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg name=\"upload\" size={newSize} block={block} viewBox=\"0 0 14 16\">\n <path\n d=\"M5.4 3.4V12H7.4V3.4L11.4 7.4L12.8 6L7.1 0.3C6.7 -0.1 6.1 -0.1 5.7 0.3L2.38419e-08 6L1.4 7.4L5.4 3.4Z\"\n transform=\"translate(0.599976)\"\n fill={color}\n />\n <path d=\"M14 0H0V2H14V0Z\" transform=\"translate(0 14)\" fill={color} />\n </Svg>\n )\n }\n}\n\nUpload.defaultProps = {\n color: 'currentColor',\n size: 16,\n block: false,\n}\n\nUpload.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n block: PropTypes.bool,\n}\n\nexport default Upload\n\n```"
}
] |
code_store-on-localhost_d2c595f8
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/UnorderedList/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 18,\n height: 12,\n}\n\nclass UnorderedList extends PureComponent {\n render() {\n const { color, size, block } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg\n name=\"unorderedList\"\n size={newSize}\n block={block}\n viewBox=\"0 0 64 64\"\n fill={color}>\n <circle fill={color} cx=\"8\" cy=\"12\" r=\"6\" />\n <circle fill={color} cx=\"8\" cy=\"32\" r=\"6\" />\n <circle fill={color} cx=\"8\" cy=\"52\" r=\"6\" />\n <path d=\"M61,13H21a1,1,0,0,1,0-2H61a1,1,0,0,1,0,2Z\" fill={color} />\n <path d=\"M46,33H21a1,1,0,0,1,0-2H46a1,1,0,0,1,0,2Z\" fill={color} />\n <path d=\"M61,53H21a1,1,0,0,1,0-2H61a1,1,0,0,1,0,2Z\" fill={color} />\n </Svg>\n )\n }\n}\n\nUnorderedList.defaultProps = {\n color: 'currentColor',\n size: 20,\n block: false,\n}\n\nUnorderedList.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n block: PropTypes.bool,\n}\n\nexport default UnorderedList\n\n```"
}
] |
code_store-on-localhost_de25740a
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/Plus/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 20,\n height: 20,\n}\n\nclass Plus extends PureComponent {\n render() {\n const { color, size, solid, block } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg\n name=\"plus\"\n variation={solid ? 'solid' : null}\n size={newSize}\n block={block}\n viewBox=\"0 0 20 20\">\n {solid ? (\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M13.6569 13.6569C16.7811 10.5326 16.7811 5.46735 13.6569 2.34316C10.5327 -0.781032 5.46739 -0.781075 2.34316 2.34316C-0.781075 5.46739 -0.781032 10.5327 2.34316 13.6569C5.46735 16.7811 10.5326 16.7811 13.6569 13.6569ZM8.00006 6.58567L10.8285 3.75724L12.2427 5.17159L9.41423 8.00001L12.2427 10.8284L10.8285 12.2425L8.00001 9.41423L5.15726 12.257L3.74309 10.8426L6.58576 7.99997L3.74313 5.15734L5.15747 3.74309L8.00006 6.58567Z\"\n transform=\"translate(10.1006 -1.31372) rotate(45)\"\n fill={color}\n />\n ) : (\n <>\n <circle cx=\"8\" cy=\"8\" r=\"7\" stroke=\"#3F3F40\" strokeWidth=\"2\" />\n <path\n d=\"M4.5 7H7V4.5C7 4.22386 7.22386 4 7.5 4H8.5C8.77614 4 9 4.22386 9 4.5V7H11.5C11.7761 7 12 7.22386 12 7.5V8.5C12 8.77614 11.7761 9 11.5 9H9V11.5C9 11.7761 8.77614 12 8.5 12H7.5C7.22386 12 7 11.7761 7 11.5V9H4.5C4.22386 9 4 8.77614 4 8.5V7.5C4 7.22386 4.22386 7 4.5 7Z\"\n fill={color}\n />\n </>\n )}\n </Svg>\n )\n }\n}\n\nPlus.defaultProps = {\n color: 'currentColor',\n size: 20,\n solid: false,\n block: false,\n}\n\nPlus.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n solid: PropTypes.bool,\n block: PropTypes.bool,\n}\n\nexport default Plus\n\n```"
}
] |
code_store-on-localhost_e9374bcf
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/ArrowDown/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 17,\n height: 16,\n}\n\nclass ArrowDown extends PureComponent {\n render() {\n const { color, size, block } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg name=\"arrow-down\" size={newSize} block={block} viewBox=\"0 0 17 16\">\n <path\n d=\"M8.39162 16C8.78498 16 9.04721 15.8667 9.30945 15.6L16.7832 8L14.9476 6.13333L9.70281 11.4667V0H7.08043V11.4667L1.83567 6.13333L3.12612e-08 8L7.47379 15.6C7.73602 15.8667 7.99826 16 8.39162 16Z\"\n fill={color}\n />\n </Svg>\n )\n }\n}\n\nArrowDown.defaultProps = {\n color: 'currentColor',\n size: 16,\n block: false,\n}\n\nArrowDown.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n block: PropTypes.bool,\n}\n\nexport default ArrowDown\n\n```"
}
] |
code_store-on-localhost_091c4bcc
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/icon/Grid/index.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport React, { PureComponent } from 'react'\nimport PropTypes from 'prop-types'\n\nimport { Svg } from '../IconBase'\nimport { calcIconSize } from '../utils'\n\nconst iconBase = {\n width: 16,\n height: 16,\n}\n\nclass Grid extends PureComponent {\n render() {\n const { color, size, block } = this.props\n const newSize = calcIconSize(iconBase, size)\n\n return (\n <Svg name=\"grid\" size={newSize} block={block}>\n <path\n d=\"M6 0H1C0.4 0 0 0.4 0 1V6C0 6.6 0.4 7 1 7H6C6.6 7 7 6.6 7 6V1C7 0.4 6.6 0 6 0Z\"\n fill={color}\n />\n <path\n d=\"M15 0H10C9.4 0 9 0.4 9 1V6C9 6.6 9.4 7 10 7H15C15.6 7 16 6.6 16 6V1C16 0.4 15.6 0 15 0Z\"\n fill={color}\n />\n <path\n d=\"M6 9H1C0.4 9 0 9.4 0 10V15C0 15.6 0.4 16 1 16H6C6.6 16 7 15.6 7 15V10C7 9.4 6.6 9 6 9Z\"\n fill={color}\n />\n <path\n d=\"M15 9H10C9.4 9 9 9.4 9 10V15C9 15.6 9.4 16 10 16H15C15.6 16 16 15.6 16 15V10C16 9.4 15.6 9 15 9Z\"\n fill={color}\n />\n </Svg>\n )\n }\n}\n\nGrid.defaultProps = {\n color: 'currentColor',\n size: 16,\n block: false,\n}\n\nGrid.propTypes = {\n color: PropTypes.string,\n size: PropTypes.number,\n block: PropTypes.bool,\n}\n\nexport default Grid\n\n```"
}
] |
code_store-on-localhost_801b07e4
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Charts/BarChart/index.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\nimport {\n BarChart as BarChartBase,\n Bar,\n CartesianGrid,\n XAxis,\n YAxis,\n ResponsiveContainer,\n Tooltip,\n} from 'recharts'\nimport PropTypes from 'prop-types'\n\nimport { getChartDefaultProps, getBarDefaultProps } from '../helpers'\nimport { BAR_GAP, Layout, chartDefaultConfig } from './constants'\nimport { colors, tooltipProps } from '../commonProps'\n\ntype Props = {\n barProps: BarProps\n}\n\nconst BarChart: FC<Props & BaseChartProps> = ({\n config,\n xAxisKey,\n data,\n yAxisKey,\n barProps,\n}) => {\n const { configs } = getChartDefaultProps(config, chartDefaultConfig)\n const { barConfigs } = getBarDefaultProps(barProps)\n const dataKey = barConfigs.layout == Layout.HORIZONTAL ? yAxisKey : xAxisKey\n\n return (\n <ResponsiveContainer {...configs.container}>\n <BarChartBase data={data} barCategoryGap={BAR_GAP} {...barConfigs}>\n <CartesianGrid {...configs.grid} />\n <XAxis dataKey={xAxisKey} dy={-5} {...configs.xAxis} />\n <YAxis dataKey={yAxisKey} dy={10} {...configs.yAxis} />\n <Tooltip {...tooltipProps} />\n <Bar dataKey={dataKey} fill={colors[1]} radius={[3, 3, 0, 0]} />\n </BarChartBase>\n </ResponsiveContainer>\n )\n}\n\nBarChart.propTypes = {\n /** The source data, in which each element is an object. */\n data: PropTypes.arrayOf(PropTypes.object).isRequired,\n\n /** The key of x-axis which is corresponding to the data. */\n xAxisKey: PropTypes.string,\n\n /** The key of y-axis which is corresponding to the data. */\n yAxisKey: PropTypes.string,\n\n /** The schema prop changes some styles of the chart.\n * This prop should be given as an object. Check an example [here](/#/Components/Charts/LineChart?id=chart-config)*/\n config: PropTypes.shape({\n xAxis: PropTypes.shape({\n axisLine: PropTypes.bool,\n tickLine: PropTypes.bool,\n tick: PropTypes.bool,\n hide: PropTypes.bool,\n }),\n yAxis: PropTypes.shape({\n axisLine: PropTypes.bool,\n tickLine: PropTypes.bool,\n tick: PropTypes.bool,\n hide: PropTypes.bool,\n }),\n container: PropTypes.shape({\n height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n }),\n grid: PropTypes.shape({\n horizontal: PropTypes.bool,\n vertical: PropTypes.bool,\n }),\n }),\n\n /** An object that will change specific bar props, like the orientation */\n barProps: PropTypes.object,\n}\n\nexport default BarChart\n\n```"
}
] |
code_store-on-localhost_da3694c4
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Charts/BarChart/sampleData.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nconst data = [\n {\n name: 'Home Page',\n uv: 4000,\n pv: 2400,\n amt: 2400,\n },\n {\n name: 'Product Page',\n uv: 3000,\n pv: 1398,\n amt: 2210,\n },\n {\n name: 'Search Page',\n uv: 2000,\n pv: 9800,\n amt: 2290,\n },\n {\n name: 'Skus Page',\n uv: 2780,\n pv: 3908,\n amt: 2000,\n },\n {\n name: 'Admin Page',\n uv: 2390,\n pv: 3800,\n amt: 2500,\n },\n]\n\nexport default data\n\n```"
}
] |
code_store-on-localhost_d2a08c23
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Charts/BarChart/README.md from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n#### The bar charts shows the data as rectangular bars. They express quantities through a bar's length, using a common baseline. The bar charts are more effective to compare discrete categories, change over time and make a ranking. \n\n```js\nconst data = require('./sampleData').default;\n\n <BarChart\n data={data}\n xAxisKey='name'\n yAxisKey='pv'\n config={{\n container: { height: '100%', width: '100%'}\n }}\n />\n```\n\n### 👍 Dos\n- Start at the zero baseline. \n\n### 👎 Don'ts\n- Rotate bar labels\n- Use bar chart like an histogram\n\n### Orientation\nThe bars can be plotted horizontally or vertically. To do this, use the prop `barProps` and set the `layout` key, according do you want. In recharts, the things are switched, so take careful with this.\n\n\n- Horizontal: `{layout: 'vertical'}`\n```js\nconst data = require('./sampleData').default;\nconst CustomizedLabel = (props) => {\n const {\n x, y, fill, payload,\n } = props\n const value = (typeof payload.value) == 'string' ? \n payload.value.split(' ')[0]: payload.value \n \n return (\n <text x={x/16} y={y} fill={fill} fontSize={14}>\n {value}\n </text>\n )\n};\n <BarChart\n data={data}\n xAxisKey='pv'\n yAxisKey='name'\n config={{\n container: { height: '60%', width: '60%'},\n xAxis: {type: 'number'}, \n yAxis: {type: 'category', tick: <CustomizedLabel/>}\n }}\n barProps={{layout: 'vertical'}}\n />\n```\n\n- Vertical: `{layout: 'horizontal'}`\n```js\nconst data = require('./sampleData').default;\n\n <BarChart\n data={data}\n xAxisKey='name'\n yAxisKey='pv'\n config={{\n container: {height: '60%', width: '60%'},\n xAxis: {type: 'category'},\n yAxis: {type: 'number'}\n }}\n barProps={{layout: 'horizontal'}}\n />\n\n```\n**OBS:** To correctly change the orientation, set both axis types.\nFor default, xAxis is a `category` and yAxis is a `number`\n\n```js static\n <BarChart\n data={data}\n xAxisKey='name'\n yAxisKey='pv'\n config={{\n xAxis: {type: 'category'},\n yAxis: {type: 'number'}\n }}\n barProps={{layout: 'horizontal'}}\n />\n```\n### Chart Config\n\nYou also can change the axis, grid and the size of the container like the `LineChart`. Follow the same instructions, described [here](/#/Components/Charts/LineChart?id=chart-config).\n\n```"
}
] |
code_store-on-localhost_af17f8b1
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Charts/BarChart/constants.ts from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport const BAR_GAP = '20%'\n\nexport enum Layout {\n VERTICAL = 'vertical',\n HORIZONTAL = 'horizontal',\n}\n\nexport const defaultProps: DefaultBarProps = {\n layout: Layout.HORIZONTAL,\n}\n\nexport const chartDefaultConfig: ChartConfig = {\n xAxis: {\n axisLine: true,\n tickLine: false,\n tickMargin: 5,\n type: 'category',\n tick: true,\n hide: false,\n },\n yAxis: {\n axisLine: true,\n tickLine: false,\n tickMargin: 10,\n type: 'number',\n tick: true,\n hide: false,\n },\n}\n\n```"
}
] |
code_store-on-localhost_f9e85f9c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Charts/BubbleChart/index.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\nimport PropTypes from 'prop-types'\n\nimport ScatterChart from '../ScatterChart'\n\nconst BubbleChart: FC<BaseChartProps> = props => <ScatterChart {...props} />\n\nBubbleChart.propTypes = {\n /** The source data, in which each element is an object. */\n data: PropTypes.arrayOf(PropTypes.object).isRequired,\n\n /** The config prop changes some styles of the chart. This prop should be given as an object.*/\n config: PropTypes.shape({\n xAxis: PropTypes.shape({\n axisLine: PropTypes.bool,\n tickLine: PropTypes.bool,\n tick: PropTypes.bool,\n hide: PropTypes.bool,\n }),\n yAxis: PropTypes.shape({\n axisLine: PropTypes.bool,\n tickLine: PropTypes.bool,\n tick: PropTypes.bool,\n hide: PropTypes.bool,\n }),\n container: PropTypes.shape({\n height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n }),\n grid: PropTypes.shape({\n horizontal: PropTypes.bool,\n vertical: PropTypes.bool,\n }),\n }),\n\n /** The key of x-axis which is corresponding to the data. */\n xAxisKey: PropTypes.string.isRequired,\n\n /** The keys of y-axis which is corresponding to the data. */\n yAxisKey: PropTypes.string.isRequired,\n\n /** The key of y-axis which is corresponding to the data, it measures size of dot. */\n zAxisKey: PropTypes.string.isRequired,\n}\n\nexport default BubbleChart\n\n```"
}
] |
code_store-on-localhost_245026cd
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Charts/BubbleChart/README.md from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n#### The Bubble Charts shows the data as points like the Scatter Plot. However, unlike a Scatter Plot, each plotted point has a third measure representing the area of its circle. They are effective to compare and show the relationships between the circles, by the use of positioning and proportions. \n\n```js\nconst data = [\n { x: 100, y: 200, z: 140 },\n { x: 120, y: 100, z: 270 },\n { x: 170, y: 300, z: 100 },\n { x: 140, y: 250, z: 80 },\n { x: 150, y: 500, z: 300 },\n { x: 110, y: 280, z: 1400 },\n];\n\n\n<BubbleChart\n config={{container: {width: '100%', height: '100%'}}}\n data={data}\n xAxisKey='x'\n yAxisKey='y'\n zAxisKey='z'\n/>\n```\n\n### 👍 Dos\n- Use legends to show how different bubble sizes correspond with values of your third variable. \n\n### 👎 Don'ts\n- Don't use a bubble chart with large datasets, too many bubbles can make the chart hard to read.\n\n### Chart Config\n\nYou also can change the axis, grid, and the size of the container like the `LineChart`. Follow the same instructions, described [here](/#/Components/Charts/LineChart?id=chart-config).\n```"
}
] |
code_store-on-localhost_5b0fb058
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Charts/LineChart/index.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\nimport zipWith from 'lodash/zipWith'\nimport curry from 'lodash/curry'\nimport {\n Line,\n LineChart as LineChartBase,\n XAxis,\n YAxis,\n Tooltip,\n CartesianGrid,\n ResponsiveContainer,\n TooltipFormatter,\n} from 'recharts'\nimport PropTypes from 'prop-types'\nimport uuid from 'uuid'\n\nimport { colors, tooltipProps } from '../commonProps'\nimport { getChartDefaultProps, getLineDefaultProps } from '../helpers'\n\ninterface Props {\n tooltipFormatter: TooltipFormatter\n lineProps: LineProps\n}\n\nconst renderLine = (lineConfigs, key, color) => (\n <Line key={uuid()} dataKey={key} stroke={color} {...lineConfigs} />\n)\n\nconst LineChart: FC<Props & BaseChartProps> = ({\n data,\n dataKeys,\n xAxisKey,\n config,\n tooltipFormatter,\n lineProps,\n}) => {\n const { configs } = getChartDefaultProps(config)\n const { lineConfigs } = getLineDefaultProps(lineProps)\n\n return (\n <ResponsiveContainer {...configs.container}>\n <LineChartBase data={data}>\n <CartesianGrid {...configs.grid} />\n <XAxis dataKey={xAxisKey} {...configs.xAxis} />\n <YAxis {...configs.yAxis} />\n <Tooltip formatter={tooltipFormatter} {...tooltipProps} />\n {zipWith(dataKeys, colors, curry(renderLine)(lineConfigs))}\n </LineChartBase>\n </ResponsiveContainer>\n )\n}\n\nLineChart.propTypes = {\n /** The source data, in which each element is an object. */\n data: PropTypes.arrayOf(PropTypes.object).isRequired,\n\n /** The keys or getter of a group of data which should be unique in a LineChart. */\n dataKeys: PropTypes.arrayOf(PropTypes.string).isRequired,\n\n /** The key of x-axis which is corresponding to the data. */\n xAxisKey: PropTypes.string.isRequired,\n\n /** The formatter function of value in tooltip. If you return an array, the first entry will be the formatted \"value\", and the second entry will be the formatted \"key\" */\n tooltipFormatter: PropTypes.func,\n\n /** The config prop changes some styles of the chart. This prop should be given as an object.*/\n config: PropTypes.shape({\n xAxis: PropTypes.shape({\n axisLine: PropTypes.bool,\n tickLine: PropTypes.bool,\n tick: PropTypes.bool,\n hide: PropTypes.bool,\n }),\n yAxis: PropTypes.shape({\n axisLine: PropTypes.bool,\n tickLine: PropTypes.bool,\n tick: PropTypes.bool,\n hide: PropTypes.bool,\n }),\n container: PropTypes.shape({\n height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n }),\n grid: PropTypes.shape({\n horizontal: PropTypes.bool,\n vertical: PropTypes.bool,\n }),\n }),\n\n /** The interpolation defines how data points should be connected when creating a path.*/\n lineProps: PropTypes.object,\n}\n\nexport default LineChart\n\n```"
}
] |
code_store-on-localhost_5430544f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Charts/LineChart/sampleData.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nconst data = [\n {\n hour: '0h',\n customers: 4000,\n orders: 2400,\n totalSpent: 2400,\n },\n {\n hour: '1h',\n customers: 3000,\n orders: 1398,\n totalSpent: 2210,\n },\n {\n hour: '2h',\n customers: 2000,\n orders: 9800,\n totalSpent: 2290,\n },\n {\n hour: '3h',\n customers: 2780,\n orders: 3908,\n totalSpent: 2000,\n },\n {\n hour: '4h',\n customers: 1890,\n orders: 4800,\n totalSpent: 2181,\n },\n {\n hour: '5h',\n customers: 2390,\n orders: 3800,\n totalSpent: 2500,\n },\n {\n hour: '6h',\n customers: 3490,\n orders: 4300,\n totalSpent: 2100,\n },\n]\n\nexport default data\n\n```"
}
] |
code_store-on-localhost_5b5ff4d6
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Charts/LineChart/multilineSample.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nconst data = [\n {\n name: 'a',\n uv: 4000,\n pv: 2400,\n amt: 2400,\n gte: 3000,\n yaw: 8000,\n },\n {\n name: 'b',\n uv: 3000,\n pv: 1398,\n amt: 2210,\n gte: 1000,\n yaw: 1200,\n },\n {\n name: 'c',\n uv: 2000,\n pv: 9800,\n amt: 2290,\n gte: 4150,\n yaw: 3500,\n },\n {\n name: 'd',\n uv: 2780,\n pv: 3908,\n amt: 2000,\n gte: 2250,\n yaw: 7000,\n },\n {\n name: 'e',\n uv: 1890,\n pv: 4800,\n amt: 2181,\n gte: 2160,\n yaw: 8456,\n },\n {\n name: 'g',\n uv: 3490,\n pv: 4300,\n amt: 2100,\n gte: 2000,\n yaw: 6570,\n },\n]\n\nexport default data\n\n```"
}
] |
code_store-on-localhost_45bd119b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Charts/LineChart/README.md from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n#### The line chart shows the data as a data points connected by a line. They are useful to analyze changes over the time, comparisons, and trends.\n\n```js\n const sampleData = require('./sampleData').default;\n const keys = ['customers', 'orders', 'totalSpent'];\n const mapper = {\n 'customers': 'Customers',\n 'orders': 'Orders',\n 'totalSpent': 'Total Spent'\n }\n const formatter = (value, name) => {\n if(name == 'totalSpent')\n value = `$${value}`\n return [value, mapper[name]]\n\n }\n <LineChart\n data={sampleData}\n dataKeys={keys}\n xAxisKey='hour'\n tooltipFormatter={formatter}\n />\n```\n\n### 👍 Dos\n- Use grids to help your audience trace their finger\nfrom the data to the axis.\n- Use axis labels clearly and concise, so, you might be want to abbreviate sometimes.\n\n\n### 👎 Don'ts\n- Avoid spaghetti chart(don't use more than 4 lines)\n```jsx noeditor\nconst sampleData = require('./multilineSample').default;\nconst keys = ['uv', 'pv', 'amt', 'gte', 'yaw'];\nconst customConfig = {container: { height: '40%', width: '40%'}};\n<LineChart\n data={sampleData}\n dataKeys={keys}\n xAxisKey='name'\n config={customConfig}\n/>\n```\n- Avoid the grid from visually competing with the data.\n\n# Chart config\nThe config prop is common to all the charts, and defines the style of the chart. This should be given as an object with styles defined for `axis`, `grid`, `container`, according to your needs. \n\n```js noeditor static\nconst config = {\n container:{\n height: 300,\n width: '100%'\n },\n xAxis: {\n axisLine: false,\n tickLine: false,\n hide: false\n },\n yAxis: {\n axisLine: false,\n tickLine: false,\n hide: false\n },\n grid: {\n horizontal: false,\n vertical: false,\n }\n};\n```\n\n#### xAxis or yAxis\nThis axis property is responsible to change the visual appearance of the axis in the chart.\n\n- `tickLine`: If set true, axis tick lines will be drawn.\n- `axisLine`: If set true, axis line will be drawn.\n- `hide`: If set true, the axis does not display in the chart.\n- `tick`: Renders a label of the axis. If you pass your component instance, it will receive\nthe props needed to render the label, like the `x` and `y` position of the tick in the line axis, the `payload` which represents the data\nand the `fill` the label color. As you can see below:\n\n```js\nconst CustomizedLabel = (props) => {\n const {\n x, y, fill, payload,\n } = props\n\n return (<text x={x} y={y} fill={fill} textAnchor=\"middle\">{`${payload.value.toUpperCase()}`}</text>)\n};\n\nconst sampleData = require('./sampleData').default;\nconst keys = ['customers'];\n\n<LineChart\n data={sampleData}\n dataKeys={keys}\n xAxisKey='hour'\n config={{\n xAxis:{tick: <CustomizedLabel />}\n }}\n/>\n```\n\n#### grid\nThe grid property is responsible to show a grid inside the chart.\n\n- `horizontal`: If set to `true`, horizontal grid lines will be drawn.\n- `vertical`: If set to `true`, vertical grid lines will be drawn.\n\n```js\nconst sampleData = require('./sampleData').default;\nconst keys = ['customers'];\n\n<LineChart\n data={sampleData}\n dataKeys={keys}\n xAxisKey='hour'\n config={{ \n xAxis:{tick: true},\n grid: {vertical: true, horizontal: true}\n }}\n/>\n```\n\n\n#### container\nThe container property is responsible to define the size of the box that will render the chart.\n\n- `height`: The percentage value of the chart's width or a fixed width.\n- `width`: The percentage value of the chart's width or a fixed height.\n\n```js\nconst sampleData = require('./sampleData').default;\nconst keys = ['customers'];\n\n<LineChart\n data={sampleData}\n dataKeys={keys}\n xAxisKey='hour'\n config={{\n xAxis: {tick: true}, \n grid: {vertical: false, horizontal: false}\n }}\n/>\n```\n\n### Line props\n\n- `type`: The interpolation type of line.\n```js\nconst sampleData = require('./sampleData').default;\nconst keys = ['customers'];\n\nconst Dropdown = require('../../Dropdown/index.js').default;\nconst options = [\n { value: 'basis', label: 'Basis' },\n { value: 'basisClosed', label: 'Basis Closed' },\n { value: 'basisOpen', label: 'Basis Open' },\n { value: 'linear', label: 'Linear' },\n { value: 'linearClosed', label: 'Linear Closed' },\n { value: 'natural', label: 'Natural' },\n { value: 'monotoneX', label: 'MonotoneX' },\n { value: 'monotoneY', label: 'MonotoneY' },\n { value: 'monotone', label: 'Monotone' },\n { value: 'step', label: 'Step' },\n { value: 'stepBefore', label: 'Step Before' },\n { value: 'stepAfter', label: 'Step After' },\n]\n\nclass InterpolationExample extends React.Component {\n constructor() {\n super();\n this.state = {\n interpolation: \"monotone\",\n };\n }\n render() {\n return (\n <div>\n <Dropdown\n label=\"Interpolation\"\n size=\"small\"\n options={options}\n value={this.state.interpolation}\n onChange={(event) => {\n this.setState({interpolation: event.target.value})\n }}\n />\n <br/> <br/>\n <LineChart\n data={sampleData}\n dataKeys={keys}\n xAxisKey='hour'\n config={{\n grid: {vertical: false, horizontal: false}\n }}\n lineProps={{type: this.state.interpolation}}\n />\n </div>\n )\n }\n}\n\n<InterpolationExample/>\n```\n\n### Formatting values on the tooltip\n\nThe formatter prop takes a `function` which will be used to render each content of tooltip. If you want to customize the content of your tooltip, make sure that your function follows this signature:\n\n```js noeditor static\nconst mapper = {\n 'customers': 'Customers',\n 'orders': 'Orders',\n 'totalSpent': 'Total Spent'\n}\n\nconst formatter = (value, name) => {\n if(name == 'totalSpent')\n value = `$${value}`\n return [value, mapper[name]]\n}\n\nconst formatter2 = (value, name) => {\n return mapper[name]\n}\n```\n\n```"
}
] |
code_store-on-localhost_931dd3b1
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Charts/LineChart/constants.ts from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport const defaultProps: DefaultLineProps = {\n type: 'monotone',\n strokeWidth: 3,\n dot: false,\n}\n\n```"
}
] |
code_store-on-localhost_d2de705f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Charts/ScatterChart/index.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\nimport {\n ScatterChart as ScatterChartBase,\n XAxis,\n YAxis,\n Tooltip,\n Scatter,\n CartesianGrid,\n ResponsiveContainer,\n ZAxis,\n} from 'recharts'\nimport PropTypes from 'prop-types'\nimport uuid from 'uuid'\n\nimport { commonDefaultProps } from './constants'\nimport { getChartDefaultProps, getRangeOfZAxis } from '../helpers'\nimport { colors } from '../commonProps'\n\nconst CustomTooltip = props => {\n return props.payload.map(item => (\n <p key={uuid()}>{`${item.dataKey}: ${item.value}`}</p>\n ))\n}\n\nconst ScatterChart: FC<BaseChartProps> = ({\n data,\n config,\n xAxisKey,\n yAxisKey,\n zAxisKey,\n}) => {\n const { configs } = getChartDefaultProps(config, commonDefaultProps)\n\n return (\n <ResponsiveContainer {...configs.container}>\n <ScatterChartBase data={data}>\n <CartesianGrid {...configs.grid} />\n <XAxis dataKey={xAxisKey} {...configs.xAxis} />\n <YAxis dataKey={yAxisKey} {...configs.yAxis} />\n {zAxisKey && (\n <ZAxis dataKey={zAxisKey} range={getRangeOfZAxis(zAxisKey, data)} />\n )}\n <Tooltip cursor={false} content={<CustomTooltip />} />\n <Scatter fill={colors[0]} />\n </ScatterChartBase>\n </ResponsiveContainer>\n )\n}\n\nScatterChart.propTypes = {\n /** The source data, in which each element is an object. */\n data: PropTypes.arrayOf(PropTypes.object).isRequired,\n\n /** The config prop changes some styles of the chart. This prop should be given as an object.*/\n config: PropTypes.shape({\n xAxis: PropTypes.shape({\n axisLine: PropTypes.bool,\n tickLine: PropTypes.bool,\n tick: PropTypes.bool,\n hide: PropTypes.bool,\n }),\n yAxis: PropTypes.shape({\n axisLine: PropTypes.bool,\n tickLine: PropTypes.bool,\n tick: PropTypes.bool,\n hide: PropTypes.bool,\n }),\n container: PropTypes.shape({\n height: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n width: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),\n }),\n grid: PropTypes.shape({\n horizontal: PropTypes.bool,\n vertical: PropTypes.bool,\n }),\n }),\n\n /** The key of x-axis which is corresponding to the data. */\n xAxisKey: PropTypes.string.isRequired,\n\n /** The keys of y-axis which is corresponding to the data. */\n yAxisKey: PropTypes.string.isRequired,\n\n /** The keys or getter of a group of data which should be unique in a ScatterChart. */\n dataKeys: PropTypes.arrayOf(PropTypes.string).isRequired,\n\n /** The key of y-axis which is corresponding to the data, it measures size of dot. */\n zAxisKey: PropTypes.string.isRequired,\n}\n\nexport default ScatterChart\n\n```"
}
] |
code_store-on-localhost_c38f9c70
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Charts/ScatterChart/README.md from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```markdown\n#### The Scatter charts shows the data as a collection of points, they are useful to detect if there's a relationship or correlation of multiple variables. \n\n```js\nconst data = [\n { x: 100, y: 200, z: 200 },\n { x: 120, y: 100, z: 260 },\n { x: 170, y: 300, z: 400 },\n { x: 140, y: 250, z: 280 },\n { x: 150, y: 400, z: 500 },\n { x: 110, y: 280, z: 200 },\n];\n\n<ScatterChart\n config={{ container: { width: '100%', height: '100%' } }}\n data={data}\n xAxisKey='x'\n yAxisKey='y'\n/>\n```\n\n### Chart Config\n\nYou also can change the axis, grid and the size of the container like the `LineChart`. Follow the same instructions, described [here](/#/Components/Charts/LineChart?id=chart-config).\n\n```"
}
] |
code_store-on-localhost_aaf637e3
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Charts/ScatterChart/constants.ts from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport const commonDefaultProps = {\n grid: {\n horizontal: true,\n vertical: false,\n },\n}\n\n```"
}
] |
code_store-on-localhost_c6fe8cdb
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Table/Toolbar/index.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\n\nimport ButtonGroup from './ButtonGroup'\nimport InputSearch, { InputSearchProps } from './InputSearch'\nimport InputAutocomplete from './InputAutocomplete'\nimport { AutocompleteInputProps } from '../../AutocompleteInput'\nimport { ORDER_CLASSNAMES, NAMESPACES } from '../constants'\nimport ActionBar from '../ActionBar'\nimport { ToolbarProvider } from './context'\nimport { useTestingContext } from '../context'\n\ninterface Composites {\n InputSearch: FC<InputSearchProps>\n ButtonGroup: FC\n InputAutocomplete: FC<AutocompleteInputProps>\n}\n\nconst Toolbar: FC & Composites = ({ children }) => {\n const { testId } = useTestingContext()\n\n const toolbarTestId = `${testId}__toolbar`\n const positionFixer =\n React.Children.count(children) > 1 ? null : (\n <div className={ORDER_CLASSNAMES.TOOLBAR_CHILD.POSITION_FIXER} />\n )\n\n return (\n <ActionBar\n id={NAMESPACES.TOOLBAR.CONTAINER}\n testId={toolbarTestId}\n order={ORDER_CLASSNAMES.TOOLBAR}\n className=\"flex flex-row flex-wrap w-100 justify-between\">\n <ToolbarProvider testId={toolbarTestId}>\n {children}\n {positionFixer}\n </ToolbarProvider>\n </ActionBar>\n )\n}\n\nToolbar.InputSearch = InputSearch\nToolbar.ButtonGroup = ButtonGroup\nToolbar.InputAutocomplete = InputAutocomplete\n\nexport default Toolbar\n\n```"
}
] |
code_store-on-localhost_dfd9d7cb
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Table/Toolbar/ButtonGroup.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\nimport classNames from 'classnames'\n\nimport { ButtonProps } from './Button'\nimport ButtonColumns, { ButtonColumnsProps } from './ButtonColumns'\nimport ButtonDensity, { ButtonDensityProps } from './ButtonDensity'\nimport ButtonDownload from './ButtonDownload'\nimport ButtonUpload from './ButtonUpload'\nimport ButtonExtraActions, {\n ButtonExtraActionsProps,\n} from './ButtonExtraActions'\nimport ButtonNewLine, { ButtonNewLineProps } from './ButtonNewLine'\nimport { NAMESPACES, ORDER_CLASSNAMES } from '../constants'\nimport { useToolbarContext, ButtonGroupProvider } from './context'\n\nconst getButton = (type: ButtonType, props: Props) => {\n switch (type) {\n case ButtonType.Columns: {\n return (\n <span\n className={ORDER_CLASSNAMES.TOOLBAR_CHILD.BUTTON_GROUP_CHILD.COLUMNS}>\n <ButtonColumns {...(props as ButtonColumnsProps)} />\n </span>\n )\n }\n case ButtonType.Density: {\n return (\n <span\n className={ORDER_CLASSNAMES.TOOLBAR_CHILD.BUTTON_GROUP_CHILD.DENSITY}>\n <ButtonDensity {...(props as ButtonDensityProps)} />\n </span>\n )\n }\n case ButtonType.Download: {\n return (\n <span\n className={\n ORDER_CLASSNAMES.TOOLBAR_CHILD.BUTTON_GROUP_CHILD.DOWNLOAD\n }>\n <ButtonDownload {...(props as ButtonProps)} />\n </span>\n )\n }\n case ButtonType.Upload: {\n return (\n <span\n className={ORDER_CLASSNAMES.TOOLBAR_CHILD.BUTTON_GROUP_CHILD.UPLOAD}>\n <ButtonUpload {...(props as ButtonProps)} />\n </span>\n )\n }\n case ButtonType.ExtraActions: {\n return (\n <span\n className={\n ORDER_CLASSNAMES.TOOLBAR_CHILD.BUTTON_GROUP_CHILD.EXTRA_ACTIONS\n }>\n <ButtonExtraActions {...(props as ButtonExtraActionsProps)} />\n </span>\n )\n }\n case ButtonType.NewLine: {\n return (\n <span\n className={ORDER_CLASSNAMES.TOOLBAR_CHILD.BUTTON_GROUP_CHILD.NEWLINE}>\n <ButtonNewLine {...(props as ButtonNewLineProps)} />\n </span>\n )\n }\n default: {\n return null\n }\n }\n}\n\nconst getComponent = (type: ButtonType) => {\n return (props: Props) => getButton(type, props)\n}\n\nconst ButtonGroup: FC & Composites = ({ children }) => {\n const { testId } = useToolbarContext()\n const buttonGroupTestId = `${testId}__button-group`\n return (\n <div\n id={NAMESPACES.TOOLBAR.BUTTON_GROUP}\n data-testid={buttonGroupTestId}\n className={classNames(\n ORDER_CLASSNAMES.TOOLBAR_CHILD.BUTTON_GROUP,\n 'flex flex-row flex-wrap items-center'\n )}>\n <ButtonGroupProvider testId={buttonGroupTestId}>\n {children}\n </ButtonGroupProvider>\n </div>\n )\n}\n\nenum ButtonType {\n Columns,\n Density,\n Download,\n Upload,\n ExtraActions,\n NewLine,\n}\n\ntype Composites = {\n Columns: FC<ButtonColumnsProps>\n Density: FC<ButtonDensityProps>\n Download: FC<ButtonProps>\n Upload: FC<ButtonProps>\n ExtraActions: FC<ButtonExtraActionsProps>\n NewLine: FC<ButtonNewLineProps>\n}\n\ntype Props =\n | ButtonProps\n | ButtonColumnsProps\n | ButtonDensityProps\n | ButtonExtraActionsProps\n | ButtonNewLineProps\n\nButtonGroup.Columns = getComponent(ButtonType.Columns)\nButtonGroup.Density = getComponent(ButtonType.Density)\nButtonGroup.Download = getComponent(ButtonType.Download)\nButtonGroup.Upload = getComponent(ButtonType.Upload)\nButtonGroup.ExtraActions = getComponent(ButtonType.ExtraActions)\nButtonGroup.NewLine = getComponent(ButtonType.NewLine)\n\nexport default ButtonGroup\n\n```"
}
] |
code_store-on-localhost_230fd488
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Table/Toolbar/ButtonColumns.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\n\nimport Toggle from '../../Toggle/index'\nimport IconColumns from '../../icon/Columns/index'\nimport usePopoverMenu, { Item, Box, Alignment } from './PopoverMenu'\nimport Button, { IconSize } from './Button'\nimport { NAMESPACES } from '../constants'\nimport useTableVisibility from '../hooks/useTableVisibility'\nimport { useButtonGroupContext } from './context'\n\nconst COLUMNS_BOX = {\n MAX_HEIGHT: 192,\n WIDTH: 292,\n ITEM_HEIGHT: 36,\n}\n\nconst ButtonColumns: FC<ButtonColumnsProps> = ({\n label,\n showAllLabel,\n hideAllLabel,\n alignMenu,\n disabled,\n visibility,\n}) => {\n const { buttonRef, boxVisible, toggleBox } = usePopoverMenu()\n const { testId } = useButtonGroupContext()\n const columnsTestId = `${testId}__columns`\n\n const {\n hiddenColumns,\n hideAllColumns,\n showAllColumns,\n toggleColumn,\n columns,\n } = visibility\n\n const height = Math.min(\n columns.length * COLUMNS_BOX.ITEM_HEIGHT,\n COLUMNS_BOX.MAX_HEIGHT\n )\n\n const boxProps = {\n height,\n alignMenu,\n width: COLUMNS_BOX.WIDTH,\n groupActions: [\n { id: 1, label: showAllLabel, onClick: showAllColumns },\n { id: 2, label: hideAllLabel, onClick: hideAllColumns },\n ],\n }\n\n return (\n <Button\n id={NAMESPACES.TOOLBAR.BUTTON_COLUMNS}\n testId={columnsTestId}\n title={label}\n ref={buttonRef}\n onClick={toggleBox}\n icon={<IconColumns size={IconSize.Medium} />}\n disabled={disabled}>\n {boxVisible && (\n <Box {...boxProps} testId={columnsTestId}>\n {columns.map((column, index) => {\n const { id, title } = column\n const togglerFn = () => toggleColumn(id)\n const isVisible = !hiddenColumns.includes(id)\n return (\n <Item key={index} onClick={togglerFn}>\n {title}\n <Toggle checked={isVisible} onChange={togglerFn} />\n </Item>\n )\n })}\n </Box>\n )}\n </Button>\n )\n}\n\nexport type ButtonColumnsProps = {\n label: string\n showAllLabel: string\n hideAllLabel: string\n alignMenu: Alignment\n disabled: boolean\n visibility: ReturnType<typeof useTableVisibility>\n}\n\nexport default ButtonColumns\n\n```"
}
] |
code_store-on-localhost_a7456df3
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Table/Toolbar/InputAutocomplete.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\nimport classNames from 'classnames'\n\nimport { NAMESPACES, ORDER_CLASSNAMES } from '../constants'\nimport AutocompleteInput, {\n AutocompleteInputProps,\n} from '../../AutocompleteInput'\nimport { useToolbarContext } from './context'\n\nconst InputAutocomplete: FC<AutocompleteInputProps> = props => {\n const { testId } = useToolbarContext()\n return (\n <span\n className={classNames(ORDER_CLASSNAMES.TOOLBAR_CHILD.INPUT, 'w-40')}\n id={NAMESPACES.TOOLBAR.INPUT_SEARCH}\n data-testid={`${testId}__input-autocomplete`}>\n <AutocompleteInput {...props} />\n </span>\n )\n}\n\nexport default InputAutocomplete\n\n```"
}
] |
code_store-on-localhost_440eb385
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Table/Toolbar/ButtonNewLine.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\n\nimport ActionMenu from '../../ActionMenu/index.js'\nimport ButtonGroup from '../../ButtonGroup/index.js'\nimport IconPlus from '../../icon/Plus/index.js'\nimport Button, {\n ButtonProps,\n ButtonVariation,\n ButtonSize,\n IconSize,\n} from './Button'\nimport { NAMESPACES } from '../constants'\nimport { MenuAction } from './PopoverMenu'\nimport { useButtonGroupContext } from './context'\n\nconst ButtonNewLine: FC<ButtonNewLineProps> = ({ actions, ...buttonProps }) => {\n const namespace = NAMESPACES.TOOLBAR.BUTTON_NEWLINE\n const { testId } = useButtonGroupContext()\n const newlineTestId = `${testId}__new-line`\n return actions ? (\n <ButtonGroup\n buttons={[\n <Button\n isActiveOfGroup\n id={namespace}\n testId={newlineTestId}\n key={namespace}\n isGrouped\n isFirstOfGroup\n variation={ButtonVariation.Primary}\n icon={<IconPlus solid size={IconSize.Light} />}\n {...buttonProps}\n />,\n <ActionMenu\n isActiveOfGroup\n id={`${namespace}__action-menu`}\n testId={`${newlineTestId}__action-menu`}\n key=\"actions-button\"\n buttonProps={buttonProps}\n options={actions}\n />,\n ]}\n />\n ) : (\n <Button\n id={NAMESPACES.TOOLBAR.BUTTON_NEWLINE}\n testId={newlineTestId}\n icon={<IconPlus solid size={IconSize.Light} />}\n variation={ButtonVariation.Primary}\n {...buttonProps}\n />\n )\n}\n\nButtonNewLine.defaultProps = {\n size: ButtonSize.Small,\n}\n\nexport type ButtonNewLineProps = ButtonProps & {\n actions: Array<MenuAction>\n}\n\nexport default ButtonNewLine\n\n```"
}
] |
code_store-on-localhost_48168d0b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Table/Toolbar/ButtonUpload.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\n\nimport IconUpload from '../../icon/Upload/index.js'\nimport { NAMESPACES } from '../constants'\nimport Button, { IconSize, ButtonProps } from './Button'\nimport { useButtonGroupContext } from './context'\n\nconst ButtonUpload: FC<ButtonProps> = props => {\n const { testId } = useButtonGroupContext()\n return (\n <Button\n id={NAMESPACES.TOOLBAR.BUTTON_UPLOAD}\n testId={`${testId}__upload`}\n icon={<IconUpload size={IconSize.Heavy} />}\n {...props}\n />\n )\n}\n\nexport default ButtonUpload\n\n```"
}
] |
code_store-on-localhost_fbb4f773
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Table/Toolbar/ButtonDensity.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\n\nimport IconDensity from '../../icon/Density/index.js'\nimport { NAMESPACES } from '../constants'\nimport Button, { IconSize } from './Button'\nimport usePopoverMenu, { Box, Item, Alignment } from './PopoverMenu'\nimport useTableMeasures, {\n Density,\n DENSITY_OPTIONS,\n} from '../hooks/useTableMeasures'\nimport { useButtonGroupContext } from './context'\n\nconst FIELDS_ITEM_HEIGHT = 36\nconst BOX_HEIGHT = DENSITY_OPTIONS.length * FIELDS_ITEM_HEIGHT\n\nconst ButtonDensity: FC<ButtonDensityProps> = ({\n label,\n handleCallback,\n disabled,\n alignMenu,\n density,\n ...options\n}) => {\n const { currentDensity, setCurrentDensity } = density\n const { buttonRef, toggleBox, setBoxVisible, boxVisible } = usePopoverMenu()\n const { testId } = useButtonGroupContext()\n const densityTestId = `${testId}__density`\n\n return (\n <Button\n id={NAMESPACES.TOOLBAR.BUTTON_DENSITY}\n testId={densityTestId}\n title={label}\n ref={buttonRef}\n onClick={toggleBox}\n icon={<IconDensity size={IconSize.Medium} />}\n disabled={disabled}>\n {boxVisible && (\n <Box testId={densityTestId} height={BOX_HEIGHT} alignMenu={alignMenu}>\n {DENSITY_OPTIONS.map((key: Density, index) => {\n const isKeySelected = currentDensity === key\n return (\n <Item\n key={index}\n isSelected={isKeySelected}\n onClick={() => {\n setCurrentDensity(key)\n setBoxVisible(false)\n handleCallback && handleCallback(key)\n }}>\n {options[`${key}Label`]}\n </Item>\n )\n })}\n </Box>\n )}\n </Button>\n )\n}\n\nexport type ButtonDensityProps = {\n density: ReturnType<typeof useTableMeasures>\n label: string\n compactLabel: string\n regularLabel: string\n comfortableLabel: string\n handleCallback: Function\n alignMenu: Alignment\n disabled: boolean\n}\n\nexport default ButtonDensity\n\n```"
}
] |
code_store-on-localhost_ec762fb3
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Table/Toolbar/ButtonExtraActions.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\n\nimport ActionMenu from '../../ActionMenu/index'\nimport IconOptionsDots from '../../icon/OptionsDots/index'\nimport { NAMESPACES } from '../constants'\nimport { MenuAction, Alignment } from './PopoverMenu'\nimport { ButtonVariation, ButtonSize } from './Button'\nimport { useButtonGroupContext } from './context'\n\nconst ButtonExtraActions: FC<ButtonExtraActionsProps> = ({\n label,\n size,\n actions,\n}) => {\n const { testId } = useButtonGroupContext()\n return (\n <div title={label} className=\"mh2 order-4\">\n <ActionMenu\n hideCaretIcon\n buttonProps={{\n variation: ButtonVariation.Tertiary,\n id: NAMESPACES.TOOLBAR.BUTTON_EXTRA_ACTIONS,\n testId: `${testId}__extra-actions`,\n icon: (\n <span className=\"c-on-base\">\n <IconOptionsDots />\n </span>\n ),\n size: size,\n }}\n options={actions.map(action => {\n return {\n label: action.label,\n onClick: action.onClick,\n }\n })}\n />\n </div>\n )\n}\n\nButtonExtraActions.defaultProps = {\n size: ButtonSize.Small,\n}\n\nexport type ButtonExtraActionsProps = {\n label?: string\n actions: Array<MenuAction>\n alignMenu?: Alignment\n isLoading?: boolean\n size?: ButtonSize\n}\n\nexport default ButtonExtraActions\n\n```"
}
] |
code_store-on-localhost_92c9d79f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Table/Toolbar/ButtonDownload.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\n\nimport IconDownload from '../../icon/Download/index.js'\nimport { NAMESPACES } from '../constants'\nimport Button, { IconSize, ButtonProps } from './Button'\nimport { useButtonGroupContext } from './context'\n\nconst ButtonDownload: FC<ButtonProps> = props => {\n const { testId } = useButtonGroupContext()\n return (\n <Button\n id={NAMESPACES.TOOLBAR.BUTTON_DOWNLOAD}\n testId={`${testId}__download`}\n icon={<IconDownload size={IconSize.Heavy} />}\n {...props}\n />\n )\n}\n\nexport default ButtonDownload\n\n```"
}
] |
code_store-on-localhost_edaa68ca
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Table/Toolbar/InputSearch.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC, FormEvent, InputHTMLAttributes } from 'react'\n\nimport Input from '../../InputSearch/index'\nimport { NAMESPACES, ORDER_CLASSNAMES } from '../constants'\nimport { useToolbarContext } from './context'\n\nexport type InputSearchProps = InputHTMLAttributes<HTMLInputElement> & {\n onSubmit: (event: FormEvent<HTMLFormElement>) => void\n}\n\nconst InputSearch: FC<InputSearchProps> = ({ onSubmit, ...inputProps }) => {\n const { testId } = useToolbarContext()\n return (\n <form\n id={NAMESPACES.TOOLBAR.INPUT_SEARCH}\n data-testid={`${testId}__search-form`}\n className={ORDER_CLASSNAMES.TOOLBAR_CHILD.INPUT}\n onSubmit={onSubmit}>\n <Input testId={`${testId}__search-form__input`} {...inputProps} />\n </form>\n )\n}\n\nexport default InputSearch\n\n```"
}
] |
code_store-on-localhost_e6350fa2
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Table/Toolbar/context.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC, useContext, createContext } from 'react'\n\nimport { E2ETestable } from '../types'\n\nconst ToolbarContext = createContext<E2ETestable>(null)\nconst ButtonGroupContext = createContext<E2ETestable>(null)\n\nexport const ToolbarProvider: FC<E2ETestable> = ({ children, testId }) => {\n return (\n <ToolbarContext.Provider value={{ testId }}>\n {children}\n </ToolbarContext.Provider>\n )\n}\n\nexport const ButtonGroupProvider: FC<E2ETestable> = ({ children, testId }) => {\n return (\n <ButtonGroupContext.Provider value={{ testId }}>\n {children}\n </ButtonGroupContext.Provider>\n )\n}\n\nexport function useToolbarContext() {\n const context = useContext(ToolbarContext)\n if (!context) {\n throw new Error('Do not use Toolbar composites outside of context')\n }\n return context\n}\n\nexport function useButtonGroupContext() {\n const context = useContext(ButtonGroupContext)\n if (!context) {\n throw new Error('Do not use ButtonGroup composites outside of context')\n }\n return context\n}\n\n```"
}
] |
code_store-on-localhost_090dc9cf
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Table/Toolbar/PopoverMenu.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, {\n useRef,\n useState,\n FC,\n useLayoutEffect,\n useCallback,\n} from 'react'\nimport classnames from 'classnames'\n\nimport Button from '../../Button/index.js'\nimport { E2ETestable } from '../types'\n\nexport default function usePopoverMenu() {\n const [boxVisible, setBoxVisible] = useState(false)\n const buttonRef = useRef(null)\n\n const handleOutsideClick = (e: Event) =>\n buttonRef &&\n buttonRef.current &&\n e.target instanceof Node &&\n !buttonRef.current.contains(e.target) &&\n setBoxVisible(false)\n\n useLayoutEffect(() => {\n if (boxVisible) {\n document.addEventListener('mousedown', handleOutsideClick)\n }\n return () => document.removeEventListener('mousedown', handleOutsideClick)\n }, [boxVisible])\n\n const toggleBox = useCallback(() => {\n setBoxVisible(!boxVisible)\n }, [boxVisible])\n\n return { boxVisible, setBoxVisible, buttonRef, toggleBox }\n}\n\nexport const Box: FC<BoxProps> = ({\n alignMenu,\n height,\n width,\n noMargin,\n borderClasses,\n groupActions,\n testId,\n children,\n}) => {\n const isAlignRight = alignMenu === Alignment.Right\n const className = classnames(\n `absolute z-999 shadow-4 ${borderClasses || 'b--muted-4 br2 ba'}`,\n {\n 'right-0': isAlignRight,\n 'left-0': !isAlignRight,\n 'mt2 mh2': !noMargin,\n }\n )\n return (\n <div\n data-testid={`${testId}__box`}\n className={className}\n style={{\n width: width,\n }}>\n <div className=\"w-100 b2 br2 bg-base\">\n {groupActions && (\n <div\n data-testid={`${testId}__box__group-actions`}\n className=\"flex inline-flex bb b--muted-4 w-100 justify-center pv4\">\n {groupActions.map(action => (\n <div\n className=\"mh2\"\n key={action.id}\n data-testid={`${testId}__group-actions--${action.id}`}>\n <Button\n variation=\"secondary\"\n size=\"small\"\n // eslint-disable-next-line react/jsx-handler-names\n onClick={action.onClick}>\n {action.label}\n </Button>\n </div>\n ))}\n </div>\n )}\n <div\n data-testid={`${testId}__box__items`}\n className=\"overflow-auto\"\n style={{ height: height }}>\n {children}\n </div>\n </div>\n </div>\n )\n}\n\nexport const Item: FC<ItemProps> = ({ isSelected, onClick, children }) => {\n const containerClassName = classnames(\n 'flex justify-between ph6 pv3 pointer hover-bg-muted-5 bl bw1',\n {\n 'b--emphasis': isSelected,\n 'b--transparent': !isSelected,\n }\n )\n const className = classnames('w-100 flex justify-between', {\n fw5: isSelected,\n })\n return (\n <div className={containerClassName} onClick={onClick}>\n <span className={className}>{children}</span>\n </div>\n )\n}\n\ntype BoxProps = E2ETestable & {\n height?: string | number\n width?: string | number\n alignMenu?: Alignment\n noMargin?: boolean\n borderClasses?: string\n groupActions?: Array<MenuAction>\n}\n\ntype ItemProps = {\n onClick?: (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void\n isSelected?: boolean\n}\n\nexport type MenuAction = {\n label: string\n onClick: Function\n toggle?: {\n checked: boolean\n semantic: boolean\n }\n id?: number | string\n}\n\nexport enum Alignment {\n Left = 'left',\n Right = 'right',\n}\n\n```"
}
] |
code_store-on-localhost_d67256b5
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Table/Toolbar/Button.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { forwardRef, ReactNode } from 'react'\nimport classNames from 'classnames'\n\nimport ButtonWithIcon from '../../ButtonWithIcon/index.js'\nimport { E2ETestable } from '../types'\n\nconst ICON_OPTICAL_COMPENSATION = { marginTop: 1.5 }\n\ntype Ref = HTMLDivElement\n\nconst Button = forwardRef<Ref, ButtonProps>(\n (\n {\n id,\n title,\n disabled,\n onClick,\n icon,\n isLoading,\n children,\n label,\n variation,\n isActiveOfGroup,\n isGrouped,\n isFirstOfGroup,\n size,\n testId,\n },\n ref\n ) => {\n const isTertiary = variation === ButtonVariation.Tertiary\n\n const iconClass = classNames('mh2', {\n 'c-on-base': isTertiary && !disabled,\n 'c-muted-2': disabled,\n })\n\n const labelClass = classNames({\n 'c-on-base': isTertiary && !disabled,\n 'c-muted-2': disabled,\n })\n\n return (\n <div\n id={`${id}__container`}\n data-testid={`${testId}__container`}\n title={title}\n ref={ref}\n className={classNames('relative', { mh2: isTertiary })}>\n <ButtonWithIcon\n icon={\n <span className={iconClass} style={ICON_OPTICAL_COMPENSATION}>\n {icon}\n </span>\n }\n testId={testId}\n isGrouped={isGrouped}\n isFirstOfGroup={isFirstOfGroup}\n isActiveOfGroup={isActiveOfGroup}\n disabled={disabled}\n isLoading={isLoading}\n variation={variation}\n size={size}\n onClick={onClick}>\n {label && <span className={labelClass}>{label}</span>}\n </ButtonWithIcon>\n {children}\n </div>\n )\n }\n)\n\nexport enum ButtonVariation {\n Primary = 'primary',\n Secondary = 'secondary',\n Tertiary = 'tertiary',\n}\n\nexport enum ButtonSize {\n Small = 'small',\n Regular = 'regular',\n Large = 'large',\n}\n\nexport enum IconSize {\n Heavy = 13,\n Medium = 14,\n Light = 16,\n}\n\nexport type ButtonProps = E2ETestable & {\n id?: string\n label?: string\n onClick?: Function\n isLoading?: boolean\n disabled?: boolean\n size?: ButtonSize\n icon?: unknown\n title?: string\n variation?: ButtonVariation\n isActiveOfGroup?: boolean\n isGrouped?: boolean\n isFirstOfGroup?: boolean\n children?: ReactNode\n}\n\nButton.defaultProps = {\n variation: ButtonVariation.Tertiary,\n isActiveOfGroup: false,\n isGrouped: false,\n isFirstOfGroup: false,\n size: ButtonSize.Small,\n}\n\nexport default Button\n\n```"
}
] |
code_store-on-localhost_05800868
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Table/BulkActions/index.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\nimport classNames from 'classnames'\n\nimport { ORDER_CLASSNAMES, NAMESPACES } from '../constants'\nimport Actions from './Actions'\nimport Tail from './Tail'\nimport useTableMotion from '../hooks/useTableMotion'\nimport ActionBar from '../ActionBar'\n\nconst BULK_ACTIONS_HEIGHT = 56\n\nconst DEFAULT_TRANSITION = {\n duration: 200,\n func: 'ease-in-out',\n delay: 0,\n optimize: false,\n}\n\nconst TRANSITIONS = [\n {\n prop: 'height',\n ...DEFAULT_TRANSITION,\n },\n {\n prop: 'padding',\n ...DEFAULT_TRANSITION,\n },\n]\n\nconst BulkActions: FC<BulkActionsProps> & Composites = ({\n active = false,\n children,\n}) => {\n const motion = useTableMotion(TRANSITIONS)\n const positionFixer =\n React.Children.count(children) > 1 ? null : (\n <div className={ORDER_CLASSNAMES.BULK_CHILD.POSITION_FIXER} />\n )\n return (\n <ActionBar\n id={NAMESPACES.BULK_ACTIONS}\n order={ORDER_CLASSNAMES.BULK}\n className={classNames(\n 'flex flex-row justify-between bg-action-primary c-on-action-primary br3 br--top ph4',\n {\n pv4: active,\n }\n )}\n style={{\n height: active ? BULK_ACTIONS_HEIGHT : 0,\n overflow: active ? 'auto' : 'hidden',\n ...motion,\n }}\n noMargin>\n {children}\n {positionFixer}\n </ActionBar>\n )\n}\n\nexport type BulkActionsProps = {\n active: boolean\n}\n\ntype Composites = {\n Actions: FC\n Tail: FC\n}\n\nBulkActions.Actions = Actions\nBulkActions.Tail = Tail\n\nexport default BulkActions\n\n```"
}
] |
code_store-on-localhost_7c0cebfc
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Table/BulkActions/Actions.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport classNames from 'classnames'\n\nimport Button from '../../Button'\nimport ActionMenu from '../../ActionMenu'\nimport { MenuAction } from '../Toolbar/PopoverMenu'\nimport { ORDER_CLASSNAMES } from '../constants'\n\nconst ACTION_MARGIN = 'mr4'\n\nexport default function Actions({ children }) {\n const className = classNames(\n 'flex flex-row',\n ORDER_CLASSNAMES.BULK_CHILD.ACTIONS\n )\n return <div className={className}>{children}</div>\n}\n\nActions.Primary = Primary\nActions.Secondary = Secondary\n\nfunction Primary({ label, onClick }: PrimaryProps) {\n const className = classNames(\n ACTION_MARGIN,\n ORDER_CLASSNAMES.BULK_CHILD.ACTIONS_CHILD.PRIMARY\n )\n return (\n <div className={className}>\n <Button variation=\"secondary\" size=\"small\" onClick={onClick}>\n {label}\n </Button>\n </div>\n )\n}\n\nfunction Secondary({ label, actions, onActionClick }: SecondaryProps) {\n const className = classNames(\n ACTION_MARGIN,\n ORDER_CLASSNAMES.BULK_CHILD.ACTIONS_CHILD.SECONDARY\n )\n return (\n <div className={className}>\n <ActionMenu\n label={label}\n buttonProps={{ variation: 'secondary', size: 'small' }}\n options={actions.map(el => ({\n label: el.label,\n onClick: () => onActionClick(el),\n }))}\n />\n </div>\n )\n}\n\ntype PrimaryProps = {\n label: string\n onClick: () => void\n}\n\ntype SecondaryProps = {\n label: string\n actions: Array<MenuAction>\n onActionClick: (el: MenuAction) => void\n}\n\n```"
}
] |
code_store-on-localhost_8d0c8a2b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Table/BulkActions/Tail.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React from 'react'\nimport classNames from 'classnames'\n\nimport ButtonWithIcon from '../../ButtonWithIcon'\nimport Close from '../../icon/Close'\nimport Button from '../../Button'\nimport { ORDER_CLASSNAMES } from '../constants'\n\nexport default function Tail({ children }) {\n const className = classNames(\n 'tr flex flex-row items-center',\n ORDER_CLASSNAMES.BULK_CHILD.RIGHT\n )\n return <div className={className}>{children}</div>\n}\n\nTail.Info = Info\nTail.Toggle = Toggle\nTail.Dismiss = Dismiss\n\nfunction Dismiss({ onClick }: { onClick: () => void }) {\n return <ButtonWithIcon icon={<Close />} onClick={onClick} />\n}\n\nfunction Info({ children }) {\n return <span className=\"mr4 c-muted-4\">{children}</span>\n}\n\nfunction Toggle({ children, button, active }) {\n const { onClick, text } = button\n return (\n <span className=\"mr2\">\n {active ? (\n children\n ) : (\n <Button onClick={onClick}>\n <span className=\"ttu\">{text}</span>\n </Button>\n )}\n </span>\n )\n}\n\n```"
}
] |
code_store-on-localhost_e9be7d7f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Table/hooks/useTableMotion.ts from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { useState, useEffect, useMemo } from 'react'\nimport throttle from 'lodash/throttle'\n\nconst defaultTransition: Transition[] = [\n {\n prop: 'all',\n duration: 200,\n func: 'ease-in-out',\n delay: 0,\n optimize: false,\n },\n]\n\nexport default function useTableMotion(transitions = defaultTransition) {\n const reducedMotion = useReducedMotion()\n const motion = useMemo(() => {\n if (reducedMotion) return {}\n\n const draftTransitions = transitions.reduce((acc, transition, index) => {\n const { prop, duration, func, delay } = transition\n const draftTransition = `${prop} ${duration}ms ${func} ${delay}ms`\n return index === 0 ? draftTransition : `${acc}, ${draftTransition}`\n }, '')\n\n const draftWillChange = transitions.reduce(\n (acc, transition) => {\n const { prop, optimize } = transition\n const skip = !optimize || acc.props.includes(prop)\n const firstItem = acc.props.length === 0\n return skip\n ? acc\n : {\n willChange: firstItem ? prop : `${acc.willChange}, ${prop}`,\n props: [...acc.props, prop],\n }\n },\n {\n willChange: '',\n props: [],\n }\n )\n\n const noOptimizations = draftWillChange.props.length === 0\n const optimization = noOptimizations\n ? {}\n : { willChange: draftWillChange.willChange }\n\n return {\n ...optimization,\n transition: draftTransitions,\n }\n }, [reducedMotion, transitions])\n\n return motion\n}\n\nfunction useReducedMotion(init = false) {\n const [reduced, setReduced] = useState(init)\n useEffect(() => {\n const mql = window.matchMedia('(prefers-reduced-motion: reduce)')\n setReduced(mql.matches)\n const handleChange = () => {\n setReduced(mql.matches)\n }\n mql.addEventListener('change', throttle(handleChange, 200))\n return () => {\n mql.removeEventListener('change', handleChange)\n }\n }, [])\n return reduced\n}\n\ntype Transition = {\n prop: string\n duration: number\n func: string\n delay: number\n optimize?: boolean\n}\n\n```"
}
] |
code_store-on-localhost_3cc369aa
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Table/hooks/useTableSort.ts from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { useReducer } from 'react'\n\nenum SortOrder {\n ASC = 'ASC',\n DSC = 'DSC',\n}\n\ntype State = {\n order?: SortOrder\n by?: string\n}\n\nenum ActionType {\n SortASC = 'SORT_ASC',\n SortDSC = 'SORT_DSC',\n Clear = 'CLEAR',\n}\n\ntype Action = {\n type: ActionType\n payload?: {\n id: string\n }\n}\n\nconst initialState: State = {\n by: null,\n order: null,\n}\n\nexport default function useTableSort() {\n const [sorted, dispatch] = useReducer(reducer, initialState)\n\n const sortASC = (id: string) =>\n dispatch({ type: ActionType.SortASC, payload: { id } })\n\n const sortDSC = (id: string) =>\n dispatch({ type: ActionType.SortDSC, payload: { id } })\n\n const clear = () => dispatch({ type: ActionType.Clear })\n\n const sort = (id: string) => {\n const { by, order } = sorted\n if (!by || by !== id) {\n sortASC(id)\n } else {\n const sortFn = order === SortOrder.ASC ? sortDSC : sortASC\n sortFn(id)\n }\n }\n\n return {\n sorted,\n clear,\n sort,\n }\n}\n\nfunction reducer(state: State, action: Action) {\n switch (action.type) {\n case ActionType.SortASC: {\n const { id } = action.payload\n return {\n by: id,\n order: SortOrder.ASC,\n }\n }\n case ActionType.SortDSC: {\n const { id } = action.payload\n return {\n by: id,\n order: SortOrder.DSC,\n }\n }\n case ActionType.Clear: {\n return initialState\n }\n default:\n return state\n }\n}\n\n```"
}
] |
code_store-on-localhost_8619f6eb
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Table/hooks/useTableProportion.ts from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { useMemo } from 'react'\n\nimport { Column } from '../types'\n\nexport default function useTableProportion({ columns, ratio }: ProportionData) {\n const calculatedWidths = useMemo(() => calculateWidths(columns, ratio), [\n columns,\n ratio,\n ])\n\n const sizedColumns = useMemo(\n () => columns.map((col, i) => ({ ...col, width: calculatedWidths[i] })),\n [calculatedWidths, columns]\n )\n\n return {\n sizedColumns,\n }\n}\n\nfunction calculateWidths(columns: Array<Column>, ratio: Array<number>) {\n const slicedRatio = ratio.slice(0, columns.length)\n const sum = (acc: number, num: number) => acc + num\n const ratioSum = slicedRatio.reduce(sum, 0)\n const fullPortion = 100\n const minPortion = fullPortion / ratioSum\n return slicedRatio.map(value => `${value * minPortion}%`)\n}\n\ntype ProportionData = {\n columns: Array<Column>\n ratio: Array<number>\n}\n\n```"
}
] |
code_store-on-localhost_3b33f879
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Table/hooks/useTableVisibility.ts from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { useMemo, useState, useCallback } from 'react'\n\nimport { Column } from '../types'\n\nexport default function useTableVisibility({\n columns,\n hiddenColumns: initHiddenColumns = [],\n}: VisibilityData) {\n const [hiddenColumns, setHiddenColumns] = useState(initHiddenColumns)\n\n const visibleColumns = useMemo(() => {\n const reducer = (acc: Array<Column>, col: Column) =>\n hiddenColumns.includes(col.id) ? acc : [...acc, col]\n\n return columns.reduce(reducer, [])\n }, [hiddenColumns, columns])\n\n const toggleColumn = useCallback((id: string) => {\n setHiddenColumns(col =>\n col.includes(id) ? col.filter(col => col !== id) : [...col, id]\n )\n }, [])\n\n const showAllColumns = () => {\n setHiddenColumns([])\n }\n\n const hideAllColumns = () => {\n setHiddenColumns(columns.map(col => col.id))\n }\n\n return {\n columns,\n visibleColumns,\n hiddenColumns,\n toggleColumn,\n showAllColumns,\n hideAllColumns,\n }\n}\n\nexport type VisibilityData = {\n columns: Column[]\n hiddenColumns?: string[]\n}\n\n```"
}
] |
code_store-on-localhost_36faee18
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Table/hooks/useTableMeasures.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport { useMemo, useState } from 'react'\n\nconst DEFAULT_SCROLLBAR_WIDTH = 17\nconst EMPTY_STATE_SIZE_IN_ROWS = 5\nexport const TABLE_HEADER_HEIGHT = 36\n\nexport default function useTableMeasures({\n size = 0,\n density = Density.Regular,\n}: MeasuresInput) {\n const [currentDensity, setCurrentDensity] = useState<Density>(density)\n\n const rowHeight = useMemo(() => getRowHeight(currentDensity), [\n currentDensity,\n ])\n\n const tableHeight = useMemo(() => calculateTableHeight(rowHeight, size), [\n rowHeight,\n size,\n ])\n\n return {\n currentDensity,\n rowHeight,\n tableHeight,\n setCurrentDensity,\n }\n}\n\nexport type MeasuresInput = {\n size: number\n density: Density\n}\n\nexport function calculateTableHeight(\n rowHeight: number,\n tableSize: number\n): number {\n const multiplicator = tableSize !== 0 ? tableSize : EMPTY_STATE_SIZE_IN_ROWS\n return TABLE_HEADER_HEIGHT + rowHeight * multiplicator + getScrollbarWidth()\n}\n\nexport function getScrollbarWidth(): number {\n if (!window || !document || !document.documentElement)\n return DEFAULT_SCROLLBAR_WIDTH\n const scrollbarWidth =\n window.innerWidth - document.documentElement.clientWidth\n return isNaN(scrollbarWidth) ? DEFAULT_SCROLLBAR_WIDTH : scrollbarWidth\n}\n\nexport enum Density {\n Compact = 'compact',\n Regular = 'regular',\n Comfortable = 'comfortable',\n}\n\nexport enum DesitySizes {\n Compact = 32,\n Regular = 48,\n Comfortable = 76,\n}\n\nexport const DENSITY_OPTIONS = [\n Density.Compact,\n Density.Regular,\n Density.Comfortable,\n]\n\nexport function getRowHeight(density: Density): number {\n switch (density) {\n case Density.Compact:\n return DesitySizes.Compact\n case Density.Regular:\n return DesitySizes.Regular\n case Density.Comfortable:\n return DesitySizes.Comfortable\n }\n}\n\n```"
}
] |
code_store-on-localhost_96bdd912
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Table/DataTable/index.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\nimport classNames from 'classnames'\n\nimport EmptyState from '../../EmptyState/index.js'\nimport { NAMESPACES, ORDER_CLASSNAMES } from '../constants'\nimport { TABLE_HEADER_HEIGHT } from '../hooks/useTableMeasures'\nimport Loading from './Loading'\nimport useTableMotion from '../hooks/useTableMotion'\nimport { E2ETestable } from '../types'\n\nconst DataTable: FC<DataTableProps> = ({\n children,\n height,\n className,\n tagName: Tag,\n empty,\n loading,\n emptyState,\n motion,\n testId,\n}) => {\n const showLoading = !empty && loading\n const showEmptyState = empty && emptyState\n return (\n <div\n style={{ minHeight: height, ...motion }}\n className={classNames(\n 'order-1 mw-100 overflow-x-auto',\n ORDER_CLASSNAMES.TABLE\n )}>\n <Tag\n id={NAMESPACES.TABLE}\n data-testid={testId}\n className={`w-100 ${className}`}\n style={{ borderSpacing: 0 }}>\n {children}\n </Tag>\n {showLoading && (\n <Loading\n testId={`${testId}__loading`}\n motion={motion}\n height={height - TABLE_HEADER_HEIGHT}>\n {typeof loading !== 'boolean' &&\n loading.renderAs &&\n loading.renderAs()}\n </Loading>\n )}\n {showEmptyState && (\n <EmptyState testId={`${testId}__empty-state`} title={emptyState.label}>\n {emptyState.children}\n </EmptyState>\n )}\n </div>\n )\n}\n\nDataTable.defaultProps = {\n tagName: 'table',\n className: '',\n}\n\nexport type DataTableProps = E2ETestable & {\n height: number\n tagName?: 'table' | 'div' | 'section'\n className?: string\n empty: boolean\n motion: ReturnType<typeof useTableMotion>\n loading?:\n | boolean\n | {\n renderAs?: () => React.ReactNode\n }\n emptyState?: {\n label?: string\n children?: Element\n }\n}\n\nexport default DataTable\n\n```"
}
] |
code_store-on-localhost_6dc39391
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Table/DataTable/Rows.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\nimport pick from 'lodash/pick'\n\nimport Row, { RowProps, ROW_TRANSITIONS } from './Row'\nimport { Column, Items } from '../types'\nimport { Density } from '../hooks/useTableMeasures'\nimport { Checkboxes } from '../../EXPERIMENTAL_useCheckboxTree/types'\nimport useTableMotion from '../hooks/useTableMotion'\nimport { CellProps } from './Cell'\n\nconst Rows: FC<RowsProps> = ({\n columns,\n items,\n onRowClick,\n cellProps,\n rowProps,\n isRowActive,\n rowHeight,\n currentDensity,\n checkboxes,\n rowKey,\n}) => {\n const motion = useTableMotion(ROW_TRANSITIONS)\n return items ? (\n <>\n {items.map(rowData => {\n const toggleChecked = () => checkboxes.toggle(rowData)\n\n const isRowChecked = checkboxes && checkboxes.isChecked(rowData)\n const isRowPartiallyChecked =\n checkboxes && checkboxes.isPartiallyChecked(rowData)\n const isRowSelected = isRowChecked || isRowPartiallyChecked\n\n const clickable = onRowClick\n ? {\n onClick: () => onRowClick({ rowData }),\n link: true,\n }\n : {}\n return (\n <Row\n {...rowProps}\n {...clickable}\n height={rowHeight}\n active={(isRowActive && isRowActive(rowData)) || isRowSelected}\n key={rowKey({ rowData })}\n motion={motion}>\n {columns.map((column: Column, cellIndex: number) => {\n const { cellRenderer, width } = column\n const data = column.condensed\n ? pick(rowData, column.condensed)\n : column.extended\n ? rowData\n : rowData[column.id]\n const content = cellRenderer\n ? cellRenderer({\n data,\n rowHeight,\n currentDensity,\n motion,\n })\n : data\n return (\n <Row.Cell {...cellProps} key={column.id} width={width}>\n {cellIndex === 0 && checkboxes && (\n <Row.Cell.Prefix>\n <span className=\"ph3\">\n <Row.Cell.Prefix.Checkbox\n checked={isRowChecked}\n partial={isRowPartiallyChecked}\n disabled={checkboxes.isDisabled(rowData)}\n onClick={toggleChecked}\n />\n </span>\n </Row.Cell.Prefix>\n )}\n {content}\n </Row.Cell>\n )\n })}\n </Row>\n )\n })}\n </>\n ) : null\n}\n\nexport type RowsProps = {\n columns: Array<Column>\n items: Items\n currentDensity: Density\n rowKey?: ({ rowData: unknown }) => string\n onRowClick?: ({ rowData: unknown }) => void\n isRowActive?: (rowData: unknown) => boolean\n rowProps?: RowProps\n rowHeight: number\n cellProps?: Pick<CellProps, 'tagName' | 'className'>\n checkboxes?: Checkboxes<unknown>\n}\n\nexport default Rows\n\n```"
}
] |
code_store-on-localhost_bd47f77b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Table/DataTable/Row.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\nimport classNames from 'classnames'\n\nimport useTableMotion from '../hooks/useTableMotion'\nimport Cell, { CellProps, CellComposites } from './Cell'\n\nconst Row: FC<RowProps> & RowComposites = ({\n tagName: Tag = 'tr',\n children,\n height,\n onClick,\n active,\n motion,\n}) => {\n const className = classNames('w-100 truncate overflow-x-hidden', {\n 'pointer hover-c-link hover-bg-muted-5': onClick,\n 'bg-action-secondary': active,\n })\n const style = {\n height,\n ...motion,\n }\n return (\n <Tag style={style} onClick={onClick} className={className}>\n {children}\n </Tag>\n )\n}\n\nRow.Cell = Cell\n\nexport const ROW_TRANSITIONS = [\n {\n prop: 'height',\n duration: 200,\n func: 'ease-in-out',\n delay: 0,\n optimize: true,\n },\n]\n\nexport type RowComposites = {\n Cell: FC<CellProps> & CellComposites\n}\n\nexport type RowProps = {\n tagName?: 'tr' | 'div' | 'ul'\n active?: boolean\n height?: number\n onClick?: () => void\n motion?: ReturnType<typeof useTableMotion>\n}\n\nexport default Row\n\n```"
}
] |
code_store-on-localhost_783c29d4
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Table/DataTable/Cell.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC, createContext, useContext, useState } from 'react'\nimport classNames from 'classnames'\n\nimport CaretDown from '../../icon/CaretDown/index.js'\nimport CaretUp from '../../icon/CaretUp/index.js'\nimport Checkbox, { CheckboxProps } from '../Checkbox'\n\nconst PREFIX_GAP = 35\nconst SUFIX_GAP = 0.5\n\nconst HoverContext = createContext<boolean>(false)\n\nfunction HoverProvider({ children, value }) {\n return <HoverContext.Provider value={value}>{children}</HoverContext.Provider>\n}\n\nfunction useHover(init = false) {\n const [hover, setHover] = useState(init)\n\n const onMouseEnter = () => setHover(true)\n const onMouseLeave = () => setHover(false)\n\n return {\n hover,\n onMouseEnter,\n onMouseLeave,\n }\n}\n\nconst Cell: FC<CellProps> & CellComposites = ({\n children,\n width,\n onClick,\n tagName: Tag = 'td',\n className: classNameProp = '',\n active = false,\n link = false,\n}) => {\n const { hover, ...events } = useHover()\n const className = classNames(\n 'v-mid ph3 pv0 tl bb b--muted-4',\n classNameProp,\n {\n pointer: onClick,\n 'hover-c-link hover-bg-muted-5': link,\n 'c-on-base': active,\n }\n )\n return (\n <Tag {...events} onClick={onClick} style={{ width }} className={className}>\n <HoverProvider value={hover}>{children}</HoverProvider>\n </Tag>\n )\n}\n\nconst Prefix: FC<PrefixProps> & PrefixComposites = ({\n children,\n depth = 0,\n}) => {\n const width = PREFIX_GAP * depth\n return (\n <>\n <div className=\"dib\" style={{ width }} />\n <div className=\"dib pr3 v-mid\">\n <div className=\"flex w-100 items-center\">{children}</div>\n </div>\n </>\n )\n}\n\nfunction Eyesight({ children, visible }) {\n const className = classNames({ dn: !visible, inline: visible }, 'absolute')\n return (\n <span className={className} style={{ marginLeft: `${SUFIX_GAP}rem` }}>\n {children}\n </span>\n )\n}\n\nconst Suffix: FC<SuffixProps> = ({ active, ascending }) => {\n const Caret = ascending ? CaretDown : CaretUp\n const hover = useContext(HoverContext)\n return (\n <Eyesight visible={active || hover}>\n <Caret className=\"ml2\" size={10} />\n </Eyesight>\n )\n}\n\nCell.Prefix = Prefix\nCell.Suffix = Suffix\nPrefix.Checkbox = Checkbox\n\ntype PrefixComposites = {\n Checkbox?: FC<CheckboxProps>\n}\n\ntype PrefixProps = {\n depth?: number\n}\n\ntype SuffixProps = {\n active: boolean\n ascending: boolean\n}\n\nexport type CellComposites = {\n Prefix?: FC<PrefixProps> & PrefixComposites\n Suffix?: FC<SuffixProps>\n}\n\nexport type CellProps = {\n id?: string\n width?: number | string | React.ReactText\n tagName?: 'td' | 'th' | 'div' | 'li'\n className?: string\n onClick?: () => void\n showArrow?: boolean\n active?: boolean\n link?: boolean\n}\n\nexport default Cell\n\n```"
}
] |
code_store-on-localhost_92846e76
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Table/DataTable/Loading.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\n\nimport Spinner from '../../Spinner/index.js'\nimport useTableMotion from '../hooks/useTableMotion'\nimport { E2ETestable } from '../types'\n\nconst Loading: FC<Props> = ({ height, motion, children, testId }) => {\n return (\n <div\n data-testid={testId}\n className=\"flex justify-center items-center\"\n style={{ height, ...motion }}>\n {children || <Spinner />}\n </div>\n )\n}\n\ntype Props = E2ETestable & {\n height: number\n motion: ReturnType<typeof useTableMotion>\n}\n\nexport default Loading\n\n```"
}
] |
code_store-on-localhost_de24f9d7
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Styleguide/components/EXPERIMENTAL_Table/DataTable/Headings.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\nimport classNames from 'classnames'\n\nimport { TABLE_HEADER_HEIGHT } from '../hooks/useTableMeasures'\nimport Row, { RowProps } from './Row'\nimport { Column } from '../types'\nimport { Checkboxes } from '../../EXPERIMENTAL_useCheckboxTree/types'\nimport Cell, { CellProps } from './Cell'\nimport useTableSort from '../hooks/useTableSort'\n\nconst Headings: FC<HeadingsProps> = ({\n columns,\n checkboxes,\n cellProps,\n rowProps,\n sorting,\n}) => {\n return (\n <Row {...rowProps} height={TABLE_HEADER_HEIGHT}>\n {columns.map((columnData: Column, headerIndex: number) => {\n const { id, title, width, sortable } = columnData\n const cellClassName = classNames('bt normal', { pointer: sortable })\n const active = sorting && sorting.sorted && sorting.sorted.by === id\n const ascending = sorting && sorting.sorted.order !== 'DSC'\n const onclick =\n sortable && sorting ? { onClick: () => sorting.sort(id) } : {}\n return (\n <Row.Cell\n {...onclick}\n {...cellProps}\n active={active}\n className={cellClassName}\n key={headerIndex}\n width={width}>\n {checkboxes && headerIndex === 0 && (\n <Cell.Prefix>\n <span className=\"ph3\">\n <Cell.Prefix.Checkbox\n checked={checkboxes.allChecked}\n partial={checkboxes.someChecked}\n disabled={checkboxes.allDisabled}\n // eslint-disable-next-line react/jsx-handler-names\n onClick={checkboxes.toggleAll}\n />\n </span>\n </Cell.Prefix>\n )}\n {title}\n {sortable && <Cell.Suffix active={active} ascending={ascending} />}\n </Row.Cell>\n )\n })}\n </Row>\n )\n}\n\nHeadings.defaultProps = {\n cellProps: {\n tagName: 'th',\n },\n}\n\ntype HeadingsProps = {\n columns: Array<Column>\n rowProps?: RowProps\n cellProps?: Pick<CellProps, 'tagName'>\n checkboxes?: Checkboxes<unknown>\n sorting?: Partial<ReturnType<typeof useTableSort>>\n}\n\nexport default React.memo(Headings)\n\n```"
}
] |
code_store-on-localhost_86b7341e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/FlexLayout/typings/global.d.ts from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { FunctionComponent } from 'react'\nimport { TachyonsScaleInput } from '../modules/valuesParser'\n\ndeclare global {\n interface StorefrontFunctionComponent<P = {}> extends FunctionComponent<P> {\n schema?: object\n getSchema?(props?: P): object\n }\n\n interface StorefrontComponent<P = {}, S = {}> extends Component<P, S> {\n schema?: object\n getSchema?(props: P): object\n }\n\n interface StorefrontElement extends ReactElement {\n schema?: object\n getSchema?(props: P): object\n }\n\n interface Gap {\n colGap: TachyonsScaleInput\n rowGap: TachyonsScaleInput\n }\n\n interface Flex {\n stretchContent: boolean\n grow: boolean\n }\n\n type BorderBase = 'top' | 'right' | 'bottom' | 'left' | 'all'\n\n interface Border {\n border: BorderBase | BorderBase[]\n borderWidth: TachyonsScaleInput\n borderColor: string\n }\n}\n\n```"
}
] |
code_store-on-localhost_6a1a6a50
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/FlexLayout/typings/css.d.ts from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module '*.css' {\n const css: any\n export default css\n}\n\n```"
}
] |
code_store-on-localhost_ba3b4f2d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/FlexLayout/components/FlexLayoutContext.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FunctionComponent, useContext, useMemo } from 'react'\n\nexport enum FlexLayoutTypes {\n NONE = 'none',\n ROW = 'row',\n COL = 'col',\n}\n\nexport interface FlexLayoutContextProps {\n parent: FlexLayoutTypes\n colGap: number\n rowGap: number\n}\n\nexport type FlexLayoutContextValue = number | FlexLayoutTypes\n\nexport type FlexLayoutContext = FlexLayoutContextProps & {\n [key: string]: FlexLayoutContextValue\n}\n\nconst FlexLayoutContext = React.createContext<FlexLayoutContext>({\n parent: FlexLayoutTypes.NONE,\n colGap: 0,\n rowGap: 0,\n})\n\nexport const FlexLayoutContextProvider: FunctionComponent<\n FlexLayoutContextProps\n> = ({ parent, colGap, rowGap, children }) => {\n const value = useMemo(\n () => ({\n parent,\n colGap,\n rowGap,\n }),\n [parent, colGap, rowGap]\n )\n\n return (\n <FlexLayoutContext.Provider value={value}>\n {children}\n </FlexLayoutContext.Provider>\n )\n}\n\nexport const useFlexLayoutContext = () => useContext(FlexLayoutContext)\n\n```"
}
] |
code_store-on-localhost_dca73971
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/FlexLayout/__tests__/valuesParser.test.js from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```javascript\nimport { parseBorders } from '../modules/valuesParser'\n\ndescribe('parseBorders', () => {\n it('should work with border as array', () => {\n const input = {\n border: ['left', 'bottom', 'right', 'top', 'all'],\n borderWidth: 1,\n borderColor: 'red',\n }\n\n const border = parseBorders(input)\n\n expect(border).toBe('bl bb br bt ba bw1 b--red')\n })\n it('should work with border as string', () => {\n const input = {\n border: 'all',\n borderWidth: 1,\n borderColor: 'red',\n }\n\n const border = parseBorders(input)\n\n expect(border).toBe('ba bw1 b--red')\n })\n})\n\n```"
}
] |
code_store-on-localhost_91879719
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/FlexLayout/hooks/responsiveWidth.ts from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport React, { ReactElement } from 'react'\nimport useDevice from '../../DeviceDetector/useDevice'\nimport { parseWidth } from '../modules/valuesParser'\n\ninterface DistributedWidthOptions {\n preserveLayoutOnMobile?: boolean\n}\n\ninterface ColWithWidth {\n element: React.ReactNode\n width: number | string\n hasDefinedWidth: boolean\n isResponsive: boolean\n}\n\n/** Distributes the available width--width that remains after subtracting\n * the widths of the columns the user has set--between the columns that do\n * not have their widths set by the user.\n *\n * For example:\n * There are 3 columns. The user sets the width for the first one to 50%.\n * This function will set the widths of the second and third columns to 25%.\n */\nconst distributeAvailableWidth = (cols: ColWithWidth[]) => {\n const { availableWidth, remainingColsNum, hasAnyWidthGrow } = cols.reduce(\n (acc, col) => {\n const isGrow = col.width === 'grow'\n const width =\n typeof col.width === 'number' ? acc.availableWidth - col.width : 0\n\n return {\n availableWidth: isGrow ? 0 : width,\n remainingColsNum: acc.remainingColsNum + (col.hasDefinedWidth ? 0 : 1),\n hasAnyWidthGrow: acc.hasAnyWidthGrow || isGrow,\n }\n },\n {\n availableWidth: 100,\n remainingColsNum: 0,\n hasAnyWidthGrow: false,\n }\n )\n\n if (availableWidth < 0 && !hasAnyWidthGrow) {\n console.warn(\n 'Total width set for columns of a flex-layout.row block exceeds 100%.'\n )\n const normalization = -(100 / availableWidth)\n cols = cols.map(col => ({\n ...col,\n width:\n typeof col.width === 'number' ? col.width * normalization : col.width,\n }))\n }\n\n return cols.map(col => {\n const definedWidth =\n typeof col.width === 'number' ? `${col.width}%` : col.width\n\n return {\n element: col.element,\n width: col.hasDefinedWidth\n ? definedWidth\n : `${Math.floor(Math.max(0, availableWidth) / remainingColsNum)}%`,\n hasDefinedWidth: col.hasDefinedWidth,\n }\n })\n}\n\nfunction isReactElement(element: any): element is ReactElement {\n return !!element && element.props\n}\n\nexport const useResponsiveWidth = (\n children: React.ReactNode,\n options: DistributedWidthOptions\n) => {\n const { device } = useDevice()\n\n const isPhone = device === 'phone'\n\n const { preserveLayoutOnMobile = false } = options || {}\n\n const cols: ColWithWidth[] = React.Children.toArray(children).map(col => {\n if (!isReactElement(col)) {\n return {\n element: col,\n width: 0,\n hasDefinedWidth: false,\n isResponsive: true,\n }\n }\n\n const width = parseWidth(\n col.props.width || (col.props.blockProps && col.props.blockProps.width)\n )\n\n if (width && typeof width === 'object') {\n return {\n element: col,\n width: isPhone ? width.mobile || 0 : width.desktop || 0,\n hasDefinedWidth: true,\n isResponsive: true,\n }\n }\n\n if (!preserveLayoutOnMobile && isPhone) {\n return {\n element: col,\n width: 0,\n hasDefinedWidth: false,\n isResponsive: false,\n }\n }\n\n if (typeof width === 'number' || typeof width === 'string') {\n return {\n element: col,\n width,\n hasDefinedWidth: true,\n isResponsive: false,\n }\n }\n\n return {\n element: col,\n width: 0,\n hasDefinedWidth: false,\n isResponsive: true,\n }\n })\n\n const isAnyColResponsive = cols.some(col => col.isResponsive)\n const breakOnMobile =\n !preserveLayoutOnMobile && isPhone && !isAnyColResponsive\n\n return {\n cols: distributeAvailableWidth(cols),\n breakOnMobile,\n }\n}\n\n```"
}
] |
code_store-on-localhost_bb1407d2
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/FlexLayout/modules/valuesParser.ts from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { fromPairs, pick, range, toPairs } from 'ramda'\n\nexport type TachyonsScaleInput = string | number | undefined\ntype Group<T, U> = { [key in keyof T]: U }\ntype TachyonsInputGroup<T> = Group<T, TachyonsScaleInput>\ninterface ResponsiveInput<T> {\n mobile: T\n desktop: T\n}\n\nconst MAX_TACHYONS_SCALE = 11\n\n//eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst isResponsiveInput = <T>(value: any): value is ResponsiveInput<T> =>\n value && value.mobile != null && value.desktop != null\n\n/** Takes a parser of units, and returns a parser that accepts either a\n * value or a responsive input of that same type of value\n * (i.e. {mobile: ..., desktop: ...}), and returns an object of the same\n * format of the input.\n */\nexport const parseResponsive = <T, U>(parse: (value: T) => U) => (\n value: T | ResponsiveInput<T>\n): null | U | { mobile: U; desktop: U } => {\n if (isResponsiveInput(value)) {\n return {\n mobile: parse(value.mobile),\n desktop: parse(value.desktop),\n }\n }\n\n return parse(value)\n}\n\n/** Verifies if the input is a valid Tachyons scale value (i.e. a number\n * between 0 to 11) and converts to number if necessary\n */\nconst parseTachyonsValue = (value: TachyonsScaleInput, name?: string) => {\n if (!value) {\n return 0\n }\n\n const supportedValues = range(0, MAX_TACHYONS_SCALE + 1).map(String)\n\n if (!supportedValues.includes(String(value))) {\n if (name) {\n console.warn(\n `Invalid ${name} value (\"${value}\"). It should be an integer between 0 and ${MAX_TACHYONS_SCALE}.`\n )\n }\n\n return 0\n }\n\n return typeof value === 'string' ? parseInt(value, 10) : value\n}\n\nexport const parseTachyonsGroup = <T>(group: TachyonsInputGroup<T>) => {\n const pairs = toPairs<TachyonsScaleInput>(group)\n\n const parsedValues = pairs.map<[string, number]>(([key, value]) => [\n key,\n parseTachyonsValue(value, key),\n ])\n\n return fromPairs(parsedValues) as Group<T, number>\n}\n\nconst parseDimension = (input: string): null | number | string => {\n if (typeof input !== 'string') {\n return null\n }\n\n if (input === 'grow') {\n return 'grow'\n }\n\n const supportedUnits = ['%']\n const match = input.match(new RegExp(`(\\\\d*)(${supportedUnits.join('|')})`))\n\n if (!match) {\n return null\n }\n\n const value = match[1]\n // TODO: support multiple units\n // const unit = match[2]\n\n if (value == null) {\n return null\n }\n\n const parsedValue = parseInt(value, 10)\n\n return parsedValue\n}\n\nexport const parseWidth = parseResponsive(parseDimension)\n\n/** TODO: allow responsive values on height\n * (and verify height usage overall)\n **/\nexport const parseHeight = parseDimension\n\n/** Maps objects keys to Tachyons classes, and returns a function\n * that parses Tachyons scale values to the mapped classes,\n * which in turn returns a string of classNames.\n **/\nconst mapToClasses = <T>(map: { [key in keyof T]: string }) => (\n props: { [key in keyof T]?: TachyonsScaleInput }\n) => {\n const pickedProps = pick(Object.keys(map), props)\n\n const parsedProps = parseTachyonsGroup(pickedProps)\n\n const mappedProps = toPairs(parsedProps).map(\n ([key, value]) => `${map[key as (keyof T)] as string}${value}`\n )\n\n return mappedProps.join(' ')\n}\n\n// TODO: allow responsive values on paddings and margins\nexport const parsePaddings = mapToClasses({\n paddingTop: 'pt',\n paddingBottom: 'pb',\n paddingLeft: 'pl',\n paddingRight: 'pr',\n})\n\nexport const parseMargins = mapToClasses({\n marginTop: 'mt',\n marginBottom: 'mb',\n marginLeft: 'ml',\n marginRight: 'mr',\n})\n\nconst borderMap = {\n top: 'bt',\n right: 'br',\n bottom: 'bb',\n left: 'bl',\n all: 'ba',\n}\n\nexport const parseBorders = ({ border, borderWidth, borderColor }: Border) => {\n const borders = border\n ? ([] as BorderBase[])\n .concat(border)\n .map(base => borderMap[base])\n .join(' ')\n : ''\n const width = borderWidth ? `bw${parseTachyonsValue(borderWidth, 'bw')}` : ''\n const color = borderColor ? `b--${borderColor.split(' ')[0]}` : ''\n\n return `${borders} ${width} ${color}`\n}\n\n```"
}
] |
code_store-on-localhost_8256c00d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/SliderLayout/typings/globals.d.ts from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { FunctionComponent } from 'react'\nimport { MaybeResponsiveValue } from 'vtex.responsive-values'\n\ndeclare global {\n interface StorefrontFunctionComponent<P = {}> extends FunctionComponent<P> {\n schema?: object\n getSchema?(props?: P): object\n }\n\n interface SliderLayoutSiteEditorProps {\n infinite: boolean\n showNavigationArrows: 'mobileOnly' | 'desktopOnly' | 'always' | 'never'\n showPaginationDots: 'mobileOnly' | 'desktopOnly' | 'always' | 'never'\n usePagination: boolean\n fullWidth: boolean\n arrowSize: MaybeResponsiveValue<number>\n }\n\n interface SliderLayoutProps {\n totalItems?: number\n label: string\n slideTransition: {\n /** Transition speed in ms */\n speed: number\n /** Transition delay in ms */\n delay: number\n timing: string\n }\n autoplay?: {\n /** Timeout duration in ms */\n timeout: number\n stopOnHover?: boolean\n }\n navigationStep: number | 'page'\n itemsPerPage: {\n desktop: number\n tablet: number\n phone: number\n }\n }\n}\n\n```"
}
] |
code_store-on-localhost_5c34e28b
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/SliderLayout/typings/vtex.css-handles.d.ts from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.css-handles' {\n export const useCssHandles = <T extends CssHandlesInput>(\n handles: T\n ): CssHandles<T> => {\n let cssHandles: CssHandles<T>\n\n // This is not actually what is returned by useCssHandles\n // just a mock for typechecking and testing.\n handles.forEach(handle => {\n cssHandles[handle] = handle\n })\n\n return cssHandles\n }\n}\n\ntype CssHandlesInput = readonly string[]\ntype ValueOf<T extends readonly any[]> = T[number]\ntype CssHandles<T extends CssHandlesInput> = Record<ValueOf<T>, string>\n\n```"
}
] |
code_store-on-localhost_693ff2de
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/SliderLayout/typings/vtex.render-runtime.d.ts from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\n/* eslint @typescript-eslint/no-explicit-any: 0 */\n/* Typings for `render-runtime` */\ndeclare module 'vtex.render-runtime' {\n import { Component, ReactElement } from 'react'\n\n export interface RenderContextProps {\n runtime: {\n account: string\n }\n }\n\n export interface InjectedRuntime {\n runtime: RenderRuntime\n }\n\n interface Pages {\n [name: string]: Page\n }\n\n interface Route {\n domain: string\n blockId: string\n canonicalPath?: string\n id: string\n params: Record<string, string>\n path: string\n title?: string\n }\n\n interface Culture {\n availableLocales: string[]\n locale: string\n language: string\n country: string\n currency: string\n }\n\n export interface RenderRuntime {\n account: string\n accountId: string\n appsEtag: string\n workspace: string\n disableSSR: boolean\n hints: {\n desktop: boolean\n mobile: boolean\n phone: boolean\n tablet: boolean\n }\n page: string\n route: Route\n version: string\n culture: Culture\n pages: Pages\n preview: boolean\n production: boolean\n publicEndpoint: string\n renderMajor: number\n query?: Record<string, string>\n start: boolean\n runtimeMeta: {\n version: string\n config?: any\n }\n settings: {\n [app: string]: any\n }\n segmentToken: string\n rootPath?: string\n workspaceCookie: string\n hasNewExtensions: boolean\n }\n\n export const Link: any\n export const NoSSR: any\n export const RenderContextConsumer: ReactElement\n export const canUseDOM: boolean\n export const withRuntimeContext: any\n export const Helmet: any\n export const useSSR: () => boolean\n export const useRuntime: () => RenderRuntime\n}\n\n```"
}
] |
code_store-on-localhost_442ccf50
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/SliderLayout/typings/vtex.device-detector.d.ts from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.device-detector' {\n export function useDevice(): {\n device: 'desktop' | 'tablet' | 'phone'\n isMobile: boolean\n }\n}\n\n```"
}
] |
code_store-on-localhost_011e977f
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/SliderLayout/typings/vtex.store-icons.d.ts from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.store-icons' {\n export const IconCaret: any\n}\n\n```"
}
] |
code_store-on-localhost_a69334a1
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/SliderLayout/typings/css.d.ts from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module '*.css' {\n const css: any\n export default css\n}\n\n```"
}
] |
code_store-on-localhost_7db9a4eb
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/SliderLayout/components/Slider.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC, useRef, Fragment } from 'react'\nimport useDevice from '../../DeviceDetector/useDevice'\nimport useCssHandles from '../../CssHandles/useCssHandles'\n\nimport { useScreenResize } from '../hooks/useScreenResize'\nimport { useTouchHandlers } from '../hooks/useTouchHandlers'\nimport { useAutoplay } from '../hooks/useAutoplay'\nimport { useSliderState } from './SliderContext'\nimport SliderTrack from './SliderTrack'\nimport Arrow from './Arrow'\nimport PaginationDots from './PaginationDots'\n\ninterface Props extends SliderLayoutSiteEditorProps {\n totalItems: number\n}\n\nconst CSS_HANDLES = ['sliderLayoutContainer', 'sliderTrackContainer'] as const\n\nconst Slider: FC<Props> = ({\n children,\n totalItems,\n infinite,\n showNavigationArrows,\n showPaginationDots,\n usePagination: shouldUsePagination,\n arrowSize,\n fullWidth,\n}) => {\n const handles = useCssHandles(CSS_HANDLES)\n const { isMobile } = useDevice()\n const { label, slidesPerPage } = useSliderState()\n const containerRef = useRef<HTMLDivElement>(null)\n const controls = `${label\n .toLowerCase()\n .trim()\n .replace(/ /g, '-')}-items`\n\n useAutoplay(infinite, containerRef)\n useScreenResize(infinite)\n const { onTouchEnd, onTouchStart, onTouchMove } = useTouchHandlers({\n infinite,\n })\n const shouldBeStaticList = slidesPerPage >= totalItems\n\n const shouldShowArrows = Boolean(\n (showNavigationArrows === 'always' ||\n (showNavigationArrows === 'mobileOnly' && isMobile) ||\n (showNavigationArrows === 'desktopOnly' && !isMobile)) &&\n !shouldBeStaticList\n )\n const shouldShowPaginationDots = Boolean(\n (showPaginationDots === 'always' ||\n (showPaginationDots === 'mobileOnly' && isMobile) ||\n (showPaginationDots === 'desktopOnly' && !isMobile)) &&\n !shouldBeStaticList\n )\n\n const touchStartHandler = (e: React.TouchEvent) =>\n shouldUsePagination && !shouldBeStaticList ? onTouchStart(e) : null\n const touchEndHandler = (e: React.TouchEvent) =>\n shouldUsePagination && !shouldBeStaticList ? onTouchEnd(e) : null\n const touchMoveHandler = (e: React.TouchEvent) =>\n shouldUsePagination && !shouldBeStaticList ? onTouchMove(e) : null\n\n return (\n <section\n onTouchStart={touchStartHandler}\n onTouchEnd={touchEndHandler}\n onTouchMove={touchMoveHandler}\n aria-roledescription=\"carousel\"\n aria-label={label}\n style={{\n WebkitOverflowScrolling: !shouldUsePagination ? 'touch' : undefined,\n paddingLeft: fullWidth ? undefined : arrowSize * 2,\n paddingRight: fullWidth ? undefined : arrowSize * 2,\n }}\n className={`w-100 flex items-center relative ${handles.sliderLayoutContainer}`}\n >\n <div\n className={`w-100 ${handles.sliderTrackContainer} ${\n shouldUsePagination ? 'overflow-hidden' : 'overflow-x-scroll'\n }`}\n ref={containerRef}\n >\n <SliderTrack totalItems={totalItems}>{children}</SliderTrack>\n </div>\n {shouldShowArrows && shouldUsePagination && (\n <Fragment>\n <Arrow\n totalItems={totalItems}\n orientation=\"left\"\n controls={controls}\n infinite={infinite}\n arrowSize={arrowSize}\n />\n <Arrow\n totalItems={totalItems}\n orientation=\"right\"\n controls={controls}\n infinite={infinite}\n arrowSize={arrowSize}\n />\n </Fragment>\n )}\n {shouldShowPaginationDots && shouldUsePagination && (\n <PaginationDots totalItems={totalItems} controls={controls} />\n )}\n </section>\n )\n}\n\nexport default Slider\n\n```"
}
] |
code_store-on-localhost_ba0d8467
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/SliderLayout/components/Arrow.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { memo, FC, ReactNode } from 'react'\nimport IconCaret from '../../StoreIcons/IconCaret'\n\nimport useCssHandles from '../../CssHandles/useCssHandles'\n\nimport { useSliderState } from './SliderContext'\n\nimport useKeyboardArrows from '../hooks/useKeyboardArrows'\nimport { useSliderControls } from '../hooks/useSliderControls'\n\ninterface Props {\n custom?: ReactNode\n orientation: 'left' | 'right'\n controls: string\n totalItems: number\n infinite: boolean\n arrowSize: number\n}\n\nconst CSS_HANDLES = ['sliderLeftArrow', 'sliderRightArrow', 'sliderArrows']\n\nconst Arrow: FC<Props> = ({\n custom,\n orientation,\n controls,\n totalItems,\n infinite,\n arrowSize,\n}) => {\n const { currentSlide, slidesPerPage, navigationStep } = useSliderState()\n const { goBack, goForward } = useSliderControls(infinite)\n\n const handles = useCssHandles(CSS_HANDLES)\n\n const isLeftEndReach = !(\n currentSlide - (navigationStep ? navigationStep : 1) >=\n 0\n )\n const isRightEndReach = !(currentSlide + 1 + slidesPerPage <= totalItems)\n const disabled =\n !infinite &&\n ((orientation === 'left' && isLeftEndReach) ||\n (orientation === 'right' && isRightEndReach))\n\n useKeyboardArrows(goBack, goForward)\n\n return (\n <button\n className={`${\n orientation === 'left'\n ? `${handles.sliderLeftArrow} left-0`\n : `${handles.sliderRightArrow} right-0`\n } ${\n handles.sliderArrows\n } absolute transparent ma2 flex items-center justify-center bn outline-0 pointer`}\n style={{ background: 'transparent' }}\n onClick={orientation === 'left' ? goBack : goForward}\n aria-controls={controls}\n aria-label={`${orientation === 'left' ? 'Previous' : 'Next'} Slide`}\n disabled={disabled}\n >\n {custom || <IconCaret size={arrowSize} orientation={orientation} thin />}\n </button>\n )\n}\n\nexport default memo(Arrow)\n\n```"
}
] |
code_store-on-localhost_dadea12c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/SliderLayout/components/PaginationDots.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { memo, FC } from 'react'\nimport useCssHandles from '../../CssHandles/useCssHandles'\n\nimport { useSliderDispatch, useSliderState } from './SliderContext'\n\nconst DOTS_DEFAULT_SIZE = 0.625\n\ninterface Props {\n controls: string\n totalItems: number\n}\n\nconst CSS_HANDLES = ['paginationDotsContainer', 'paginationDot'] as const\n\nconst getSelectedDot = (\n passVisibleSlides: boolean,\n currentSlide: number,\n slidesToShow: number\n): number => {\n const realCurrentSlide = passVisibleSlides\n ? currentSlide + (slidesToShow - 1)\n : currentSlide\n return passVisibleSlides\n ? Math.floor(realCurrentSlide / slidesToShow)\n : realCurrentSlide\n}\n\nconst getSlideIndices = (\n slidesToShow: number,\n passVisibleSlides: boolean,\n totalItems: number\n): number[] =>\n slidesToShow\n ? [\n ...Array(\n passVisibleSlides ? Math.ceil(totalItems / slidesToShow) : totalItems\n ).keys() as any,\n ]\n : []\n\nconst PaginationDots: FC<Props> = ({ controls, totalItems }) => {\n const {\n slideWidth,\n slidesPerPage,\n currentSlide,\n navigationStep,\n } = useSliderState()\n const dispatch = useSliderDispatch()\n const handles = useCssHandles(CSS_HANDLES)\n const passVisibleSlides = navigationStep === slidesPerPage\n\n const slideIndexes = getSlideIndices(\n slidesPerPage,\n passVisibleSlides,\n totalItems\n )\n\n const handleDotClick = (index: number) => {\n const slideToGo = passVisibleSlides ? index * slidesPerPage : index\n const isLastDot = index === slideIndexes.length - 1\n const isExactDivision = totalItems % slidesPerPage === 0\n const overslideThreshold =\n !isExactDivision && isLastDot ? Math.floor(totalItems / slidesPerPage) : 0\n\n dispatch({\n type: 'SLIDE',\n payload: {\n transform: -(slideWidth * (slideToGo - overslideThreshold)),\n currentSlide: index,\n },\n })\n }\n\n return (\n <div\n className={`${handles.paginationDotsContainer} flex absolute justify-center pa0 ma0 bottom-0 left-0 right-0`}\n role=\"group\"\n aria-label=\"Carousel Dots\"\n >\n {slideIndexes.map(index => {\n const isActive =\n index ===\n getSelectedDot(passVisibleSlides, currentSlide, slidesPerPage)\n return (\n <div\n className={`${handles.paginationDot} ${\n isActive ? 'bg-emphasis' : 'bg-muted-3'\n } grow dib br-100 pa2 mr2 ml2 bw0 pointer outline-0`}\n style={{\n height: `${DOTS_DEFAULT_SIZE}rem`,\n width: `${DOTS_DEFAULT_SIZE}rem`,\n }}\n key={index}\n tabIndex={index}\n onKeyDown={() => handleDotClick(index)}\n onClick={() => handleDotClick(index)}\n role=\"button\"\n aria-controls={controls}\n aria-label={`Dot ${index + 1} of ${slideIndexes.length}`}\n />\n )\n })}\n </div>\n )\n}\n\nexport default memo(PaginationDots)\n\n```"
}
] |
code_store-on-localhost_a3a17d1d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/SliderLayout/components/SliderTrack.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { FC } from 'react'\nimport useListContext from '../../ListContext/useListContext'\nimport useCssHandles from '../../CssHandles/useCssHandles'\n\nimport { useSliderState } from './SliderContext'\n\nconst CSS_HANDLES = ['sliderTrack', 'slide', 'slideChildrenContainer']\n\nconst SliderTrack: FC<{ totalItems: number }> = ({ children, totalItems }) => {\n const {\n transform,\n slideWidth,\n slidesPerPage,\n currentSlide,\n isOnTouchMove,\n slideTransition: { speed, timing, delay },\n } = useSliderState()\n const handles = useCssHandles(CSS_HANDLES)\n const { list } = useListContext()\n\n const childrenArray = React.Children.toArray(children).concat(list)\n\n const isSlideVisible = (\n index: number,\n currentSlide: number,\n slidesToShow: number\n ): boolean => {\n return index >= currentSlide && index < currentSlide + slidesToShow\n }\n\n return (\n <div\n className={`${handles.sliderTrack} flex justify-around relative pa0 ma0`}\n style={{\n transition: isOnTouchMove\n ? undefined\n : `transform ${speed}ms ${timing}`,\n transitionDelay: `${delay}ms`,\n transform: `translate3d(${transform}%, 0, 0)`,\n width:\n slidesPerPage < totalItems\n ? `${(totalItems * 100) / slidesPerPage}%`\n : '100%',\n }}\n aria-atomic=\"false\"\n aria-live=\"polite\"\n >\n {childrenArray.map((child, index) => (\n <div\n key={index}\n className={`flex relative ${handles.slide}`}\n data-index={index}\n style={{\n width: `${slideWidth}%`,\n }}\n aria-hidden={\n isSlideVisible(index, currentSlide, slidesPerPage)\n ? 'false'\n : 'true'\n }\n role=\"group\"\n aria-roledescription=\"slide\"\n aria-label={`${index + 1} of ${totalItems}`}\n >\n <div\n className={`${handles.slideChildrenContainer} flex justify-center items-center w-100`}\n >\n {child}\n </div>\n </div>\n ))}\n </div>\n )\n}\n\nexport default SliderTrack\n\n```"
}
] |
code_store-on-localhost_0840e099
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/SliderLayout/components/SliderContext.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\nimport React, { createContext, useReducer, useContext, FC } from 'react'\nimport useDevice from '../../DeviceDetector/useDevice'\n\ninterface AdjustOnResizeAction {\n type: 'ADJUST_ON_RESIZE'\n payload: {\n shouldCorrectItemPosition: boolean\n slidesPerPage: number\n navigationStep: number\n }\n}\n\ninterface SlideAction {\n type: 'SLIDE'\n payload: {\n transform: number\n currentSlide: number\n }\n}\n\ninterface TouchAction {\n type: 'TOUCH'\n payload: {\n transform?: number\n isOnTouchMove: boolean\n }\n}\n\ninterface State extends SliderLayoutProps {\n /** Width of each slide */\n slideWidth: number\n /** Number of slides to show per page */\n slidesPerPage: number\n /** Index of the leftmost slide of the current page */\n currentSlide: number\n /** Current transform value */\n transform: number\n /** Total number of slides */\n totalItems: number\n /** Number of slides to slide in navigation */\n navigationStep: number\n /** Whether or not navigationStep prop is set to 'page' */\n isPageNavigationStep: boolean\n /** Whether or not a touchmove event is happening */\n isOnTouchMove: boolean\n}\n\ntype Action = AdjustOnResizeAction | SlideAction | TouchAction\ntype Dispatch = (action: Action) => void\n\nconst SliderStateContext = createContext<State | undefined>(undefined)\nconst SliderDispatchContext = createContext<Dispatch | undefined>(undefined)\n\nfunction sliderContextReducer(state: State, action: Action): State {\n switch (action.type) {\n case 'ADJUST_ON_RESIZE':\n return {\n ...state,\n slidesPerPage: action.payload.slidesPerPage,\n navigationStep: action.payload.navigationStep,\n transform: action.payload.shouldCorrectItemPosition\n ? -state.slideWidth * state.currentSlide\n : state.transform,\n }\n case 'SLIDE':\n return {\n ...state,\n transform: action.payload.transform,\n currentSlide: action.payload.currentSlide,\n }\n case 'TOUCH':\n return {\n ...state,\n transform: action.payload.transform || state.transform,\n isOnTouchMove: action.payload.isOnTouchMove,\n }\n default:\n return state\n }\n}\n\nconst SliderContextProvider: FC<SliderLayoutProps & { totalItems: number }> = ({\n autoplay,\n children,\n totalItems,\n label = 'slider',\n navigationStep = 'page',\n slideTransition = {\n speed: 400,\n delay: 0,\n timing: '',\n },\n itemsPerPage = {\n desktop: 5,\n tablet: 3,\n phone: 1,\n },\n}) => {\n const { device } = useDevice()\n const resolvedNavigationStep =\n navigationStep === 'page' ? itemsPerPage[device] : navigationStep\n\n const [state, dispatch] = useReducer(sliderContextReducer, {\n slideWidth: 100 / totalItems,\n slidesPerPage: itemsPerPage[device],\n currentSlide: 0,\n transform: 0,\n navigationStep: resolvedNavigationStep,\n slideTransition,\n itemsPerPage,\n label,\n autoplay,\n totalItems,\n isPageNavigationStep: navigationStep === 'page',\n isOnTouchMove: false,\n })\n\n return (\n <SliderStateContext.Provider value={state}>\n <SliderDispatchContext.Provider value={dispatch}>\n {children}\n </SliderDispatchContext.Provider>\n </SliderStateContext.Provider>\n )\n}\n\nfunction useSliderState() {\n const context = useContext(SliderStateContext)\n if (context === undefined) {\n throw new Error(\n 'useSliderState must be used within a SliderContextProvider'\n )\n }\n return context\n}\n\nfunction useSliderDispatch() {\n const context = useContext(SliderDispatchContext)\n\n if (context === undefined) {\n throw new Error(\n 'useSliderDispatch must be used within a SliderContextProvider'\n )\n }\n return context\n}\n\nexport { SliderContextProvider, useSliderDispatch, useSliderState }\n\n```"
}
] |
code_store-on-localhost_17d2983d
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/SliderLayout/hooks/useTouchHandlers.ts from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { useState } from 'react'\n\nimport { useSliderControls } from './useSliderControls'\nimport { useSliderDispatch, useSliderState } from '../components/SliderContext'\n\nconst SWIPE_THRESHOLD = 75\n\nexport const useTouchHandlers = ({ infinite }: { infinite: boolean }) => {\n const dispatch = useSliderDispatch()\n const { transform } = useSliderState()\n const { goForward, goBack } = useSliderControls(infinite)\n\n const [touchState, setTouchState] = useState({\n touchStartX: 0,\n touchInitialTransform: transform,\n })\n\n const onTouchStart = (e: React.TouchEvent) => {\n const startX = e.touches[0].clientX\n setTouchState({ touchStartX: startX, touchInitialTransform: transform })\n }\n\n const onTouchMove = (e: React.TouchEvent) => {\n const currentX = e.touches[0].clientX\n\n const newTransform =\n touchState.touchInitialTransform +\n (currentX - touchState.touchStartX) / 100\n\n dispatch({\n type: 'TOUCH',\n payload: { transform: newTransform, isOnTouchMove: true },\n })\n }\n\n const onTouchEnd = (e: React.TouchEvent) => {\n const endX = e.changedTouches[0].clientX\n const delta = endX - touchState.touchStartX\n\n if (Math.abs(delta) > SWIPE_THRESHOLD) {\n // Swipe from left to right\n if (delta > 0) {\n goBack()\n }\n\n // Swipe from right to left\n if (delta < 0) {\n goForward()\n }\n } else {\n // Ignore the swipe if the SWIPE_THRESHOLD is not reached\n dispatch({\n type: 'TOUCH',\n payload: {\n transform: touchState.touchInitialTransform,\n isOnTouchMove: false,\n },\n })\n }\n\n setTouchState({ touchStartX: 0, touchInitialTransform: transform })\n dispatch({\n type: 'TOUCH',\n payload: {\n isOnTouchMove: false,\n },\n })\n }\n\n return { onTouchEnd, onTouchStart, onTouchMove }\n}\n\n```"
}
] |
code_store-on-localhost_157e370e
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/SliderLayout/hooks/useScreenResize.ts from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { useEffect } from 'react'\nimport useDevice from '../../DeviceDetector/useDevice'\n\nimport { useSliderDispatch, useSliderState } from '../components/SliderContext'\n\nexport const useScreenResize = (infinite: boolean) => {\n const {\n navigationStep,\n isPageNavigationStep,\n itemsPerPage,\n } = useSliderState()\n const { device } = useDevice()\n const dispatch = useSliderDispatch()\n\n useEffect(() => {\n const setNewState = (shouldCorrectItemPosition: boolean) => {\n dispatch({\n type: 'ADJUST_ON_RESIZE',\n payload: {\n shouldCorrectItemPosition,\n slidesPerPage: itemsPerPage[device],\n navigationStep: isPageNavigationStep\n ? itemsPerPage[device]\n : navigationStep,\n },\n })\n }\n const onResize = (value?: UIEvent): void => {\n setNewState(!value || infinite)\n }\n setNewState(false)\n\n window.addEventListener('resize', onResize)\n return () => window.removeEventListener('resize', onResize)\n }, [\n infinite,\n dispatch,\n itemsPerPage,\n device,\n isPageNavigationStep,\n navigationStep,\n ])\n}\n\n```"
}
] |
code_store-on-localhost_50702e1c
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/SliderLayout/hooks/useAutoplay.ts from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { useEffect } from 'react'\nimport { useSliderState } from '../components/SliderContext'\nimport { useSliderControls } from './useSliderControls'\nimport useHovering from './useHovering'\n\nexport const useAutoplay = (\n infinite: boolean,\n containerRef: React.RefObject<HTMLDivElement>\n) => {\n const { autoplay } = useSliderState()\n const { isHovering } = useHovering(containerRef)\n\n const shouldStop = autoplay && autoplay.stopOnHover && isHovering\n\n const { goForward } = useSliderControls(infinite)\n\n useEffect(() => {\n if (!autoplay) {\n return\n }\n\n const timeout = setTimeout(() => {\n goForward()\n }, autoplay.timeout)\n\n shouldStop && clearTimeout(timeout)\n\n return () => clearTimeout(timeout)\n }, [goForward, shouldStop, autoplay])\n}\n\n```"
}
] |
code_store-on-localhost_0a487a67
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/SliderLayout/hooks/useSliderControls.ts from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { useSliderDispatch, useSliderState } from '../components/SliderContext'\n\nexport const useSliderControls = (infinite: boolean) => {\n const {\n currentSlide,\n slidesPerPage,\n slideWidth,\n totalItems,\n navigationStep,\n } = useSliderState()\n const dispatch = useSliderDispatch()\n\n const goBack = () => {\n let nextSlide = 0\n let nextTransformValue = 0\n\n const nextMaximumSlides = currentSlide - navigationStep\n\n if (nextMaximumSlides >= 0) {\n /** Have more slides hidden on left */\n nextSlide = nextMaximumSlides\n nextTransformValue = -(slideWidth * nextSlide)\n } else if (nextMaximumSlides < 0 && currentSlide !== 0) {\n /** Prevent overslide */\n nextSlide = 0\n nextTransformValue = 0\n } else if (infinite) {\n /** If reach start, go to last slide */\n nextSlide = totalItems - slidesPerPage\n nextTransformValue = -(slideWidth * nextSlide)\n }\n\n dispatch({\n type: 'SLIDE',\n payload: {\n transform: nextTransformValue,\n currentSlide: nextSlide,\n },\n })\n }\n\n const goForward = () => {\n let nextSlides = 0\n let nextPosition = 0\n\n const nextMaximumSlides = currentSlide + 1 + slidesPerPage + navigationStep\n\n if (nextMaximumSlides <= totalItems) {\n /** Have more slides hidden on right */\n nextSlides = currentSlide + navigationStep\n nextPosition = -(slideWidth * nextSlides)\n } else if (\n nextMaximumSlides > totalItems &&\n currentSlide !== totalItems - slidesPerPage\n ) {\n /** Prevent overslide */\n nextSlides = totalItems - slidesPerPage\n nextPosition = -(slideWidth * nextSlides)\n } else if (infinite) {\n /** if reach end go to first slide */\n nextSlides = 0\n nextPosition = -(slideWidth * nextSlides)\n }\n\n dispatch({\n type: 'SLIDE',\n payload: {\n transform: nextPosition,\n currentSlide: nextSlides,\n },\n })\n }\n\n return { goForward, goBack }\n}\n\n```"
}
] |
code_store-on-localhost_ceaa3d55
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/SliderLayout/hooks/useKeyboardArrows.ts from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { useEffect } from 'react'\n\n/**\n * Adds event listener to call passed functions by pressing the left or right arrows\n * @param onLeft Function that is called on left arrow key press\n * @param onRight Function that is called on arrow arrow key press\n */\nconst useKeyboardArrows = (onLeft: () => void, onRight: () => void) => {\n useEffect(() => {\n const onKeyDown = (event: KeyboardEvent) => {\n event.code === 'ArrowLeft' && onLeft()\n event.code === 'ArrowRight' && onRight()\n }\n\n window.addEventListener('keydown', onKeyDown)\n\n return () => {\n window.removeEventListener('keydown', onKeyDown)\n }\n }, [onLeft, onRight])\n}\n\nexport default useKeyboardArrows\n\n```"
}
] |
code_store-on-localhost_c153bb49
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/SliderLayout/hooks/useHovering.ts from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { useState, useEffect } from 'react'\n\n/**\n * Hook that returns the hover state of a passed ref\n * @param ref React ref\n */\nconst useHovering = (ref: React.RefObject<HTMLDivElement>) => {\n const [isHovering, setHovering] = useState(false)\n\n const onMouseEnter = () => setHovering(true)\n const onMouseLeave = () => setHovering(false)\n\n useEffect(() => {\n if (ref && ref.current) {\n ref.current.addEventListener('mouseenter', onMouseEnter)\n ref.current.addEventListener('mouseleave', onMouseLeave)\n }\n\n return () => {\n const { current } = ref\n if (current) {\n current.removeEventListener('mouseenter', onMouseEnter)\n current.removeEventListener('mouseleave', onMouseLeave)\n }\n }\n }, [ref])\n\n return { isHovering }\n}\n\nexport default useHovering\n\n```"
}
] |
code_store-on-localhost_5e8d56e4
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/AddToCartButton/typings/vtex.checkout-resources.d.ts from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.checkout-resources/Mutations'\ndeclare module 'vtex.checkout-resources/Utils'\n\n```"
}
] |
code_store-on-localhost_bc0d691a
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/AddToCartButton/typings/global.d.ts from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ninterface OrderForm {\n items: Item[]\n shipping?: Shipping\n marketingData: Maybe<OrderFormMarketingData>\n totalizers: Array<{\n id: string\n name: string\n value: number\n }>\n value: number\n messages: OrderFormMessages\n}\n\ninterface OrderFormItemInput {\n id?: number\n index?: number\n quantity?: number\n seller?: string\n uniqueId?: string\n options?: AssemblyOptionInput[]\n}\n\ninterface AssemblyOptionItem {\n id: string\n quantity: number\n seller: string\n initialQuantity: number\n choiceType: 'SINGLE' | 'TOGGLE' | 'MULTIPLE'\n name: string\n price: number\n children: Record<string, AssemblyOptionItem[]> | null\n}\n\ninterface BuyButtonContextState {\n clicked: boolean\n}\n\ninterface ProductContextState {\n selectedItem: Maybe<ProductContextItem>\n product: Maybe<Product>\n selectedQuantity: number\n skuSelector: {\n isVisible: boolean\n areAllVariationsSelected: boolean\n }\n buyButton: BuyButtonContextState\n assemblyOptions: {\n items: Record<string, AssemblyOptionItem[]>\n inputValues: Record<string, InputValues>\n areGroupsValid: Record<string, boolean>\n }\n}\n\ntype InputValues = Record<string, string>\n\ninterface Product {\n cacheId: string\n productName: string\n productId: string\n description: string\n titleTag: string\n metaTagDescription: string\n linkText: string\n productReference: string\n categoryId: string\n categoriesIds: string[]\n categories: string[]\n categoryTree: {\n id: string\n name: string\n href: string\n }[]\n brand: string\n brandId: string\n properties: {\n name: string\n values: string\n }[]\n specificationGroups: {\n name: string\n specifications: {\n name: string\n values: string[]\n }[]\n }[]\n items: ProductContextItem[]\n itemMetadata: {\n items: ItemMetadata[]\n priceTable: any[]\n }\n}\n\ninterface ProductContextItem {\n itemId: string\n name: string\n nameComplete: string\n complementName: string\n ean: string\n referenceId: {\n Key: string\n Value: string\n }[]\n measurementUnit: string\n unitMultiplier: number\n images: {\n imageId: string\n imageLabel: string\n imageTag: string\n imageUrl: string\n imageText: string\n }[]\n videos: {\n videoUrl: string\n }[]\n sellers: Seller[]\n variations: {\n name: string\n values: string[]\n }[]\n productClusters: {\n id: string\n name: string\n }[]\n clusterHighlights: {\n id: string\n name: string\n }[]\n}\n\ninterface Seller {\n sellerId: string\n sellerName: string\n addToCartLink: string\n sellerDefault: string\n commertialOffer: {\n discountHighlights: {\n name: string\n }[]\n teasers: {\n name: string\n }[]\n Price: number\n ListPrice: number\n PriceWithoutDiscount: number\n RewardValue: number\n PriceValidUntil: string\n AvailableQuantity: number\n Tax: number\n CacheVersionUsedToCallCheckout: string\n }\n}\n\ninterface ItemMetadata {\n items: {\n id: string\n name: string\n imageUrl: string\n seller: string\n assemblyOptions: {\n id: string\n name: string\n required: boolean\n inputValues: InputValue[]\n composition: Composition | null\n }\n }[]\n priceTable: {\n type: string\n values: {\n id: string\n assemblyId: string\n price: number | null\n }[]\n }[]\n}\n\ntype InputValue = TextInputValue | BooleanInputValue | OptionsInputValue\n\nenum InputValueType {\n 'TEXT' = 'TEXT',\n 'BOOLEAN' = 'BOOLEAN',\n 'OPTIONS' = 'OPTIONS',\n}\n\ninterface TextInputValue {\n type: InputValueType.TEXT\n defaultValue: ''\n label: string\n maxLength: number\n domain: null\n}\n\ninterface BooleanInputValue {\n type: InputValueType.BOOLEAN\n defaultValue: boolean\n label: string\n maxLength: null\n domain: null\n}\n\ninterface OptionsInputValue {\n type: InputValueType.OPTIONS\n defaultValue: string\n label: string\n maxLength: null\n domain: string[]\n}\n\ninterface Composition {\n minQuantity: number\n maxQuantity: number\n items: {\n id: string\n minQuantity: number\n maxQuantity: number\n priceTable: string\n seller: string\n initialQuantity: number\n }[]\n}\n\ninterface OrderFormMarketingData {\n utmCampaign?: string\n utmMedium?: string\n utmSource?: string\n utmiCampaign?: string\n utmiPart?: string\n utmipage?: string\n marketingTags?: string\n coupon?: string\n}\n\ninterface Shipping {\n availableAddresses: CheckoutAddress[]\n countries: string[]\n deliveryOptions: DeliveryOption[]\n selectedAddress: CheckoutAddress | null\n}\n\ninterface CheckoutAddress {\n addressId: string\n addressType: string\n city: string | null\n complement: string | null\n country: string\n geoCoordinates: number[]\n neighborhood: string | null\n number: string | null\n postalCode: string | null\n receiverName: string | null\n reference: string | null\n state: string | null\n street: string | null\n}\n\ninterface DeliveryOption {\n id: string\n price: number\n estimate: string\n isSelected: boolean\n}\n\ninterface OrderFormMessages {\n couponMessages: Message[]\n generalMessages: Message[]\n}\n\ninterface Message {\n code: string\n text: string\n status: string\n}\n\ninterface AssemblyOptionInput {\n id?: string\n quantity?: number\n assemblyId: string\n seller?: string\n inputValues?: Record<string, string | boolean>\n options?: AssemblyOptionInput[]\n}\n\ninterface Item {\n additionalInfo: {\n brandName: string\n brandId: string\n offeringInfo: any | null\n offeringType: any | null\n offeringTypeId: any | null\n }\n availability: string\n detailUrl: string\n id: string\n imageUrls?: {\n at1x: string\n at2x: string\n at3x: string\n }\n listPrice: number\n measurementUnit: string\n name: string\n price: number\n productId: string\n quantity: number\n sellingPrice: number\n skuName: string\n skuSpecifications: SKUSpecification[]\n uniqueId: string\n}\n\ninterface SKUSpecification {\n fieldName: string\n fieldValues: string[]\n}\n\n```"
}
] |
code_store-on-localhost_6194e752
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/AddToCartButton/__tests__/index.test.tsx from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```tsx\ndescribe('Orders List Scenarios', () => {\n it('should work', () => {\n expect(1).toBe(1)\n })\n})\n\n```"
}
] |
code_store-on-localhost_e26376da
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/AddToCartButton/modules/compareObjects.ts from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nexport function compareObjects(obj1: any, obj2: any) {\n //Loop through properties in object 1\n for (const p in obj1) {\n //Check property exists on both objects\n if (obj1.hasOwnProperty(p) !== obj2.hasOwnProperty(p)) return false\n\n switch (typeof obj1[p]) {\n //Deep compare objects\n case 'object':\n if (!compareObjects(obj1[p], obj2[p])) return false\n break\n //Compare function code\n case 'function':\n if (\n typeof obj2[p] == 'undefined' ||\n (p != 'compare' && obj1[p].toString() != obj2[p].toString())\n )\n return false\n break\n //Compare values\n default:\n if (obj1[p] != obj2[p]) return false\n }\n }\n\n //Check object 2 for any extra properties\n for (const p in obj2) {\n if (typeof obj1[p] == 'undefined') return false\n }\n return true\n}\n\n```"
}
] |
code_store-on-localhost_55ed9407
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/AddToCartButton/modules/catalogItemToCart.ts from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport { path } from 'ramda'\n\nimport {\n transformAssemblyOptions,\n sumAssembliesPrice,\n ParsedAssemblyOptionsMeta,\n Option,\n} from './assemblyOptions'\n\ninterface MapCatalogItemToCartArgs {\n product: Maybe<Product>\n selectedItem: Maybe<ProductContextItem>\n selectedQuantity: number\n selectedSeller: any\n assemblyOptions?: {\n items: Record<string, AssemblyOptionItem[]>\n inputValues: Record<string, Record<string, string>>\n areGroupsValid: Record<string, boolean>\n }\n}\n\nexport interface MapCatalogItemToCartReturn {\n index: 0\n quantity: number\n detailUrl: string\n name: string\n brand: string\n category: string\n productRefId: string\n seller: any\n price: number\n listPrice: number\n variant: string\n skuId: string\n imageUrl: string | undefined\n sellingPriceWithAssemblies: number\n options: Option[]\n assemblyOptions: ParsedAssemblyOptionsMeta\n}\n\nexport function mapCatalogItemToCart({\n product,\n selectedItem,\n selectedQuantity,\n selectedSeller,\n assemblyOptions,\n}: MapCatalogItemToCartArgs): MapCatalogItemToCartReturn[] {\n return (\n product &&\n selectedItem &&\n selectedSeller &&\n selectedSeller.commertialOffer && [\n {\n index: 0,\n quantity: selectedQuantity,\n detailUrl: `/${product.linkText}/p`,\n name: product.productName,\n brand: product.brand,\n category:\n product.categories && product.categories.length > 0\n ? product.categories[0]\n : '',\n productRefId: product.productReference,\n seller: selectedSeller.sellerId,\n price: selectedSeller.commertialOffer.Price,\n listPrice: selectedSeller.commertialOffer.ListPrice,\n variant: selectedItem.name,\n skuId: selectedItem.itemId,\n imageUrl: path(['images', '0', 'imageUrl'], selectedItem),\n ...transformAssemblyOptions(\n path(['items'], assemblyOptions),\n path(['inputValues'], assemblyOptions),\n selectedSeller.commertialOffer.Price,\n selectedQuantity\n ),\n sellingPriceWithAssemblies:\n selectedSeller.commertialOffer.Price +\n sumAssembliesPrice(path(['items'], assemblyOptions) || {}),\n },\n ]\n )\n}\n\n```"
}
] |
code_store-on-localhost_66e97c38
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/AddToCartButton/modules/assemblyOptions.ts from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ntype GroupId = string\ntype GroupTypes = 'SINGLE' | 'TOGGLE' | 'MULTIPLE'\n\nexport function sumAssembliesPrice(\n assemblyOptions: Record<GroupId, AssemblyOptionItem[]>\n) {\n const cleanAssemblies = assemblyOptions || {}\n const assembliesGroupItems = Object.values(cleanAssemblies)\n return assembliesGroupItems.reduce<number>(\n (sum: number, groupItems: AssemblyOptionItem[]) => {\n const groupPrice = groupItems.reduce<number>((groupSum, item) => {\n const childrenPrice: number = item.children\n ? sumAssembliesPrice(item.children)\n : 0\n const itemCost = item.price * item.quantity\n return groupSum + itemCost + childrenPrice * item.quantity\n }, 0)\n return groupPrice + sum\n },\n 0\n )\n}\n\ntype InputValue = Record<string, string | boolean>\n\nexport interface AssemblyOptions {\n items: Record<GroupId, AssemblyOptionItem[]>\n inputValues: Record<GroupId, InputValue>\n areGroupsValid: Record<string, boolean>\n}\n\nexport type Option = ItemOption\n\nexport interface ItemOption {\n assemblyId: string\n id?: string\n quantity?: number\n seller?: string\n options?: Option[]\n inputValues?: InputValue\n}\n\ninterface AddedItem {\n id: string\n name: string\n quantity: number\n sellingPrice: number\n sellingPriceWithAssemblies: number\n assemblyOptions?: ParsedAssemblyOptionsMeta\n}\n\ninterface CartAddedOption {\n normalizedQuantity: number\n extraQuantity: number\n choiceType: GroupTypes\n item: AddedItem\n}\n\ninterface CartRemovedOption {\n name: string\n initialQuantity: number\n removedQuantity: number\n}\n\nexport interface ParsedAssemblyOptionsMeta {\n added: CartAddedOption[]\n removed: CartRemovedOption[]\n parentPrice: number\n}\n\ninterface ParsedAssemblyOptions {\n options: Option[]\n assemblyOptions: ParsedAssemblyOptionsMeta\n}\n\nexport function transformAssemblyOptions(\n assemblyOptionsItems: Record<GroupId, AssemblyOptionItem[]> = {},\n inputValues: Record<GroupId, InputValue> = {},\n parentPrice: number,\n parentQuantity: number\n): ParsedAssemblyOptions {\n // contains options sent as arguments to graphql mutation\n const options: Option[] = []\n\n // array with added assemblies data to show in minicart optimistic preview\n const added: CartAddedOption[] = []\n\n // array with removed assemblies data to show in minicart optimistic preview\n const removed: CartRemovedOption[] = []\n\n const assemblyItemsKeys: GroupId[] = Object.keys(assemblyOptionsItems)\n\n for (const groupId of assemblyItemsKeys) {\n const items = assemblyOptionsItems[groupId]\n for (const item of items) {\n const childrenAddedData = item.children\n ? transformAssemblyOptions(\n item.children,\n {},\n item.price,\n item.quantity * parentQuantity\n )\n : null\n\n const {\n options: childrenOptions,\n assemblyOptions: childrenAssemblyOptions,\n } = childrenAddedData || {\n options: undefined,\n assemblyOptions: undefined,\n }\n\n const { quantity, initialQuantity } = item\n\n if (quantity >= initialQuantity && quantity > 0) {\n added.push({\n normalizedQuantity: quantity,\n extraQuantity: quantity - initialQuantity,\n choiceType: item.choiceType,\n item: {\n name: item.name,\n sellingPrice: item.price,\n quantity,\n sellingPriceWithAssemblies:\n item.price + sumAssembliesPrice(item.children || {}),\n id: item.id,\n ...(childrenAssemblyOptions\n ? { assemblyOptions: childrenAssemblyOptions }\n : {}),\n },\n })\n }\n\n if (quantity < initialQuantity && item.choiceType === 'TOGGLE') {\n removed.push({\n name: item.name,\n initialQuantity,\n removedQuantity: initialQuantity - quantity,\n })\n }\n\n const addedChildrenCount = childrenAddedData\n ? childrenAddedData.options.length\n : 0\n\n if (quantity !== initialQuantity || addedChildrenCount > 0) {\n options.push({\n assemblyId: groupId,\n id: item.id,\n quantity: quantity * parentQuantity,\n seller: item.seller,\n ...(childrenOptions && childrenOptions.length > 0\n ? { options: childrenOptions }\n : {}),\n })\n }\n }\n }\n\n const assemblyInputValuesKeys: GroupId[] = Object.keys(inputValues)\n\n for (const groupId of assemblyInputValuesKeys) {\n const inputValuesObject = inputValues[groupId] || {}\n if (Object.keys(inputValuesObject).length > 0) {\n options.push({\n assemblyId: groupId,\n inputValues: inputValues[groupId],\n })\n }\n }\n\n return {\n options,\n assemblyOptions: {\n added,\n removed,\n parentPrice,\n },\n }\n}\n\n```"
}
] |
code_store-on-localhost_fb4eccb7
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/AddToCartButton/typings/vtex.product-context/ProductDispatchContext.d.ts from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.product-context/ProductDispatchContext'\n\n```"
}
] |
code_store-on-localhost_e63192ef
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ResponsiveValues/typings/vtex.device-detector.d.ts from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.device-detector' {\n interface Device {\n device: 'phone' | 'tablet' | 'desktop'\n isMobile: boolean\n }\n\n export function useDevice(): Device\n}\n\n```"
}
] |
code_store-on-localhost_346b44a4
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ResponsiveValues/__tests__/normalizeResponsiveInput.ts from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport {\n isResponsiveInput,\n normalizeResponsiveInput,\n} from '../hooks/normalizeResponsiveInput'\n\nconsole.warn = jest.fn()\n\ndescribe('useResponsiveValue', () => {\n afterEach(() => {\n jest.clearAllMocks()\n })\n describe('isResponsiveInput', () => {\n it('should return false if passed null', () => {\n const value = null\n\n expect(isResponsiveInput(value)).toBe(false)\n })\n it('should return false if passed a non-object', () => {\n const value = 2\n\n expect(isResponsiveInput(value)).toBe(false)\n })\n it('should return true if passed an object with a single device', () => {\n const value = {\n desktop: 1,\n }\n\n expect(isResponsiveInput(value)).toBe(true)\n })\n it('should return true if passed an object with all devices', () => {\n const value = {\n desktop: 1,\n mobile: 1,\n tablet: 1,\n phone: 1,\n }\n\n expect(isResponsiveInput(value)).toBe(true)\n })\n it('should return false if passed an object with an extraneous key', () => {\n const value = {\n desktop: 1,\n mobile: 1,\n tablet: 1,\n phone: 1,\n oops: 0,\n }\n\n expect(isResponsiveInput(value)).toBe(false)\n })\n })\n\n describe('responsiveValue', () => {\n it('should complain if \"mobile\" is defined along with \"tablet\"', () => {\n const value = {\n tablet: 1,\n phone: 1,\n mobile: 2,\n desktop: 3,\n }\n\n const result = normalizeResponsiveInput(value)\n\n expect(console.warn).toBeCalled()\n\n expect(result).toStrictEqual({\n phone: 1,\n tablet: 1,\n desktop: 3,\n })\n })\n\n it('should return an object with equal keys if the input has all the parameters', () => {\n const value = {\n desktop: 1,\n tablet: 2,\n phone: 3,\n }\n\n expect(normalizeResponsiveInput(value)).toStrictEqual({\n desktop: 1,\n tablet: 2,\n phone: 3,\n })\n })\n\n describe('fallbacks', () => {\n describe('single values should populate the object', () => {\n it('should work with straight values', () => {\n const value = 1\n\n expect(normalizeResponsiveInput(value)).toStrictEqual({\n desktop: 1,\n tablet: 1,\n phone: 1,\n })\n })\n it('should work with \"desktop\"', () => {\n const value = { desktop: 1 }\n\n expect(normalizeResponsiveInput(value)).toStrictEqual({\n desktop: 1,\n tablet: 1,\n phone: 1,\n })\n })\n it('should work with \"mobile\"', () => {\n const value = { mobile: 1 }\n\n expect(normalizeResponsiveInput(value)).toStrictEqual({\n desktop: 1,\n tablet: 1,\n phone: 1,\n })\n })\n it('should work with \"tablet\"', () => {\n const value = { tablet: 1 }\n\n expect(normalizeResponsiveInput(value)).toStrictEqual({\n desktop: 1,\n tablet: 1,\n phone: 1,\n })\n })\n it('should work with \"phone\"', () => {\n const value = {\n phone: 1,\n }\n\n expect(normalizeResponsiveInput(value)).toStrictEqual({\n desktop: 1,\n tablet: 1,\n phone: 1,\n })\n })\n })\n it('tablet should fallback to desktop instead of phone, when both are defined', () => {\n const value = {\n desktop: 1,\n phone: 2,\n }\n\n expect(normalizeResponsiveInput(value)).toStrictEqual({\n desktop: 1,\n tablet: 1,\n phone: 2,\n })\n })\n it('desktop should fallback to tablet instead of phone, when both are defined', () => {\n const value = {\n tablet: 1,\n phone: 2,\n }\n\n expect(normalizeResponsiveInput(value)).toStrictEqual({\n desktop: 1,\n tablet: 1,\n phone: 2,\n })\n })\n it('phone should fallback to tablet instead of desktop, when both are defined', () => {\n const value = {\n tablet: 1,\n desktop: 2,\n }\n\n expect(normalizeResponsiveInput(value)).toStrictEqual({\n desktop: 2,\n tablet: 1,\n phone: 1,\n })\n })\n it('tablet should fallback to mobile, ', () => {\n const value = {\n phone: 1,\n mobile: 2,\n desktop: 3,\n }\n\n expect(normalizeResponsiveInput(value)).toStrictEqual({\n desktop: 3,\n tablet: 2,\n phone: 1,\n })\n })\n it('phone and tablet should override mobile', () => {\n const value = {\n phone: 1,\n mobile: 2,\n tablet: 3,\n desktop: 4,\n }\n\n expect(normalizeResponsiveInput(value)).toStrictEqual({\n phone: 1,\n tablet: 3,\n desktop: 4,\n })\n })\n })\n })\n})\n\n```"
}
] |
code_store-on-localhost_dd774daf
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ResponsiveValues/__tests__/useResponsiveValue.ts from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport {\n useResponsiveValue,\n useResponsiveValues,\n} from '../hooks/useResponsiveValue'\n\n/** TODO: useDevice always returns 'desktop'\n * Multiple devices test cases should be tested */\n\ndescribe('useResponsiveValue', () => {\n it('should return a single value for the current device', () => {\n const input = {\n desktop: 1,\n mobile: 2,\n }\n\n const value = useResponsiveValue(input)\n\n expect(value).toBe(1)\n })\n\n it('should return a single value if the input is also a single value', () => {\n const input = 1\n\n const value = useResponsiveValue(input)\n\n expect(value).toBe(1)\n })\n})\n\ndescribe('useResponsiveValues', () => {\n it('should return the correct values for different keys', () => {\n const input = {\n first: {\n desktop: 1,\n mobile: 2,\n },\n second: {\n desktop: 3,\n mobile: 4,\n },\n }\n\n const { first, second } = useResponsiveValues(input)\n\n expect(first).toBe(1)\n expect(second).toBe(3)\n })\n})\n\n```"
}
] |
code_store-on-localhost_fa26ee10
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ResponsiveValues/hooks/normalizeResponsiveInput.ts from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\n/** The user is able to input `mobile` as a device (as opposed to `desktop`),\n * but the output will be converted to `phone` and `tablet` */\nexport enum InputDevices {\n mobile = 'mobile',\n phone = 'phone',\n tablet = 'tablet',\n desktop = 'desktop',\n}\n\nexport enum OutputDevices {\n phone = 'phone',\n tablet = 'tablet',\n desktop = 'desktop',\n}\n\nexport type ResponsiveInput<T> = { [P in keyof typeof InputDevices]?: T }\nexport type MaybeResponsiveInput<T> = T | ResponsiveInput<T>\n\nexport type ResponsiveOutput<T> = { [P in keyof typeof OutputDevices]: T }\n\n//eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst isUndefined = (value: any) => typeof value === 'undefined'\n\n/** Returns the first argument that is not undefined */\nconst firstDefinedValue = <T>(...values: T[]): T =>\n values.find(value => !isUndefined(value)) as T\n\n/** Returns the first value of the input that is not undefined,\n * given a sorted array of keys */\nconst fallbackOrder = <T>(\n input: ResponsiveInput<T>,\n devices: (keyof ResponsiveInput<T>)[]\n) => firstDefinedValue(...devices.map(key => input[key])) as T\n\n/** Checks if the input value is a ResponsiveInput type (an object with\n * one or more keys of Device type--e.g. `desktop`, `mobile`) */\n//eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const isResponsiveInput = <T>(value: any): value is ResponsiveInput<T> =>\n Boolean(\n value &&\n Object.keys(InputDevices).some(device => !isUndefined(value[device])) &&\n Object.keys(value).every(key => key in InputDevices)\n )\n\nconst showWarnings = <T>(value: ResponsiveInput<T>) => {\n if (!isUndefined(value.mobile)) {\n let devices: string[] = []\n if (!isUndefined(value.phone)) {\n devices.push('\"phone\"')\n }\n if (!isUndefined(value.tablet)) {\n devices.push('\"tablet\"')\n }\n if (devices.length === 0) {\n return\n }\n const devicesLabel = devices.join(' and ')\n console.warn(\n `You are defining a \"mobile\" value along with ${devicesLabel} ${\n devices.length > 1 ? 'values' : 'value'\n } in the props of a component. Please use \"phone\" and \"tablet\" in this case.`\n )\n }\n}\n\n/** Takes an input that might be a responsive object or not\n * (i.e. either \"prop: {mobile: 1, desktop:2}\" or just \"prop: 2\")\n * and returns an object of the values broken down into devices\n * (i.e. {phone: 1, tablet: 1, desktop: 2})\n */\nexport const normalizeResponsiveInput = <T>(\n value: MaybeResponsiveInput<T>\n): ResponsiveOutput<T> => {\n if (isResponsiveInput(value)) {\n const { mobile, tablet, phone, desktop } = InputDevices\n\n showWarnings(value)\n\n return {\n phone: fallbackOrder(value, [phone, mobile, tablet, desktop]),\n tablet: fallbackOrder(value, [tablet, mobile, desktop, phone]),\n desktop: fallbackOrder(value, [desktop, tablet, phone, mobile]),\n }\n }\n\n return {\n phone: value,\n tablet: value,\n desktop: value,\n }\n}\n\n```"
}
] |
code_store-on-localhost_7da062b6
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/ResponsiveValues/hooks/useResponsiveValue.ts from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\nimport useDevice from '../../DeviceDetector/useDevice'\nimport {\n normalizeResponsiveInput,\n MaybeResponsiveInput,\n} from './normalizeResponsiveInput'\n\nconst useResponsiveValue = <T>(input: MaybeResponsiveInput<T>): T => {\n const { device } = useDevice()\n\n return normalizeResponsiveInput(input)[device]\n}\n\nconst useResponsiveValues = <U>(input: U): U => {\n const { device } = useDevice()\n\n const keys = Object.keys(input) as (keyof U)[]\n\n let returnValue = { ...input }\n\n keys.forEach(key => {\n returnValue[key] = normalizeResponsiveInput(input[key])[device]\n })\n\n return returnValue\n}\n\nexport { useResponsiveValue, useResponsiveValues }\n\n```"
}
] |
code_store-on-localhost_9ec6b952
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Menu/constants/Options.ts from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\n\nexport default {\n EXTERNAL: 'external',\n INTERNAL: 'internal',\n LEFT: 'left',\n MIDDLE: 'middle',\n RIGHT: 'right',\n}\n```"
}
] |
code_store-on-localhost_1c15b593
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Menu/typings/vtex.css-handles.d.ts from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.css-handles' {\n export const useCssHandles\n export const withCssHandles\n}\n```"
}
] |
code_store-on-localhost_cb007f24
|
[
{
"role": "system",
"content": "You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms."
},
{
"role": "user",
"content": "Show me the implementation of store-on-localhost/src/monobloco/components/new/Menu/typings/vtex.store-components.d.ts from the store-on-localhost VTEX app."
},
{
"role": "assistant",
"content": "Here's the implementation:\n\n```typescript\ndeclare module 'vtex.store-components' {\n export const Container\n}\n```"
}
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.