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