69 lines
1.6 KiB
TypeScript
69 lines
1.6 KiB
TypeScript
import { DomTools } from './domtools.classes.domtools';
|
|
|
|
export const desktop = 1240;
|
|
export const tablet = 700;
|
|
export const phablet = 500;
|
|
export const phone = 400;
|
|
|
|
export type TViewport = 'native' | 'desktop' | 'tablet' | 'phablet' | 'phone';
|
|
|
|
export const getEnvironment = (): TViewport => {
|
|
if (globalThis.deesDomTools && globalThis.deesDomTools.domToolsStatePart.getState().virtualViewport) {
|
|
return globalThis.deesDomTools.domToolsStatePart.getState().virtualViewport;
|
|
} else {
|
|
return 'native';
|
|
}
|
|
};
|
|
|
|
export const cssForTablet = (contentArg) => {
|
|
if (getEnvironment() === 'native' || getEnvironment() === 'desktop') {
|
|
return `
|
|
@media (max-width: ${tablet}px) {
|
|
${contentArg}
|
|
}
|
|
`;
|
|
} else if (
|
|
getEnvironment() === 'tablet' ||
|
|
getEnvironment() === 'phablet' ||
|
|
getEnvironment() === 'phone'
|
|
) {
|
|
return `
|
|
@media (min-width: 0px) {
|
|
${contentArg}
|
|
}
|
|
`;
|
|
}
|
|
};
|
|
|
|
export const cssForPhablet = (contentArg) => {
|
|
if (getEnvironment() === 'native' || getEnvironment() === 'desktop') {
|
|
return `
|
|
@media (max-width: ${phablet}px) {
|
|
${contentArg}
|
|
}
|
|
`;
|
|
} else if (getEnvironment() === 'phablet' || getEnvironment() === 'phone') {
|
|
return `
|
|
@media (min-width: 0px) {
|
|
${contentArg}
|
|
}
|
|
`;
|
|
}
|
|
};
|
|
|
|
export const cssForPhone = (contentArg) => {
|
|
if (getEnvironment() === 'native' || getEnvironment() === 'desktop') {
|
|
return `
|
|
@media (max-width: ${phone}px) {
|
|
${contentArg}
|
|
}
|
|
`;
|
|
} else if (getEnvironment() === 'phone') {
|
|
return `
|
|
@media (min-width: 0px) {
|
|
${contentArg}
|
|
}
|
|
`;
|
|
}
|
|
};
|