oceanic-transcripts
Version:
A nicely formatted html transcript generator for oceanic.js.
104 lines • 4.59 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getImageStyle = exports.getGalleryLayout = exports.getSelectTypeLabel = void 0;
const oceanic_js_1 = require("oceanic.js");
const styles_1 = require("./styles");
/**
* Gets the appropriate label for different select menu types
*/
const getSelectTypeLabel = (type) => {
switch (type) {
case oceanic_js_1.ComponentTypes.USER_SELECT:
return 'Select User';
case oceanic_js_1.ComponentTypes.ROLE_SELECT:
return 'Select Role';
case oceanic_js_1.ComponentTypes.MENTIONABLE_SELECT:
return 'Select Mentionable';
case oceanic_js_1.ComponentTypes.CHANNEL_SELECT:
return 'Select Channel';
case oceanic_js_1.ComponentTypes.STRING_SELECT:
return 'Make a Selection';
default:
return 'Select Option';
}
};
exports.getSelectTypeLabel = getSelectTypeLabel;
/**
* Gets the grid layout for media galleries based on count
*/
const getGalleryLayout = (count) => {
if (count === 1) {
return Object.assign(Object.assign({}, styles_1.containerStyle), { gridTemplateColumns: '1fr', gridTemplateRows: 'auto' });
}
else if (count === 2) {
return Object.assign(Object.assign({}, styles_1.containerStyle), { gridTemplateColumns: '1fr 1fr', gridTemplateRows: 'auto' });
}
else if (count === 3 || count === 4) {
return Object.assign(Object.assign({}, styles_1.containerStyle), { gridTemplateColumns: '1fr 1fr', gridTemplateRows: '1fr 1fr' });
}
else if (count === 5) {
return Object.assign(Object.assign({}, styles_1.containerStyle), { gridTemplateColumns: '1fr 1fr 1fr', gridTemplateRows: 'auto auto' });
}
else if (count >= 7) {
return Object.assign(Object.assign({}, styles_1.containerStyle), { gridTemplateColumns: '1fr 1fr 1fr', gridTemplateRows: 'auto auto auto auto' });
}
else {
return Object.assign(Object.assign({}, styles_1.containerStyle), { gridTemplateColumns: '1fr 1fr 1fr', gridTemplateRows: 'auto' });
}
};
exports.getGalleryLayout = getGalleryLayout;
/**
* Gets the style for an individual image based on its position and total count
*/
const getImageStyle = (idx, count) => {
if (count === 3 && idx === 0) {
return Object.assign(Object.assign({}, styles_1.baseImageStyle), { gridRow: '1 / span 2', gridColumn: '1', aspectRatio: '1/2' });
}
if (count === 5) {
if (idx < 2) {
return Object.assign(Object.assign({}, styles_1.baseImageStyle), { gridRow: '1', gridColumn: idx === 0 ? '1 / span 2' : '3' });
}
else {
return Object.assign(Object.assign({}, styles_1.baseImageStyle), { gridRow: '2', gridColumn: `${idx - 2 + 1}` });
}
}
if (count === 7) {
if (idx === 0) {
return Object.assign(Object.assign({}, styles_1.baseImageStyle), { gridRow: '1', gridColumn: '1 / span 3' });
}
else if (idx <= 3) {
return Object.assign(Object.assign({}, styles_1.baseImageStyle), { gridRow: '2', gridColumn: `${idx - 0}` });
}
else {
return Object.assign(Object.assign({}, styles_1.baseImageStyle), { gridRow: '3', gridColumn: `${idx - 3}` });
}
}
if (count === 8) {
if (idx < 2) {
return Object.assign(Object.assign({}, styles_1.baseImageStyle), { gridRow: '1', gridColumn: idx === 0 ? '1 / span 2' : '3' });
}
else if (idx < 5) {
return Object.assign(Object.assign({}, styles_1.baseImageStyle), { gridRow: '2', gridColumn: `${idx - 2 + 1}` });
}
else {
return Object.assign(Object.assign({}, styles_1.baseImageStyle), { gridRow: '3', gridColumn: `${idx - 5 + 1}` });
}
}
if (count === 10) {
if (idx === 0) {
return Object.assign(Object.assign({}, styles_1.baseImageStyle), { gridRow: '1', gridColumn: '1 / span 3' });
}
else if (idx <= 3) {
return Object.assign(Object.assign({}, styles_1.baseImageStyle), { gridRow: '2', gridColumn: `${idx - 0}` });
}
else if (idx <= 6) {
return Object.assign(Object.assign({}, styles_1.baseImageStyle), { gridRow: '3', gridColumn: `${idx - 3}` });
}
else {
return Object.assign(Object.assign({}, styles_1.baseImageStyle), { gridRow: '4', gridColumn: `${idx - 6}` });
}
}
return styles_1.baseImageStyle;
};
exports.getImageStyle = getImageStyle;
//# sourceMappingURL=utils.js.map