2020-05-27 21:15:38 +00:00
|
|
|
import { DomTools } from './domtools.classes.domtools';
|
|
|
|
|
2020-05-23 15:00:01 +00:00
|
|
|
export const desktop = 1240;
|
|
|
|
export const tablet = 700;
|
|
|
|
export const phablet = 500;
|
|
|
|
export const phone = 340;
|
|
|
|
|
2020-05-27 21:15:38 +00:00
|
|
|
export type TViewport = 'native' | 'desktop' | 'tablet' | 'phablet' | 'phone';
|
2020-05-23 15:00:01 +00:00
|
|
|
|
2020-05-27 21:15:38 +00:00
|
|
|
export const getEnvironment = async (): Promise<TViewport> => {
|
|
|
|
const domToolsInstance = await DomTools.setupDomTools();
|
|
|
|
return domToolsInstance.domToolsStatePart.getState().virtualViewport;
|
2020-05-23 15:00:01 +00:00
|
|
|
};
|
|
|
|
|
2020-05-27 21:15:38 +00:00
|
|
|
export const cssForTablet = async contentArg => {
|
|
|
|
if ((await getEnvironment()) === 'native' || (await getEnvironment()) === 'desktop') {
|
2020-05-23 15:00:01 +00:00
|
|
|
return `
|
|
|
|
@media (max-width: ${tablet}px) {
|
|
|
|
${contentArg}
|
|
|
|
}
|
|
|
|
`;
|
2020-05-27 21:15:38 +00:00
|
|
|
} else if (
|
|
|
|
(await getEnvironment()) === 'tablet' ||
|
|
|
|
(await getEnvironment()) === 'phablet' ||
|
|
|
|
(await getEnvironment()) === 'phone'
|
|
|
|
) {
|
2020-05-23 15:00:01 +00:00
|
|
|
return `
|
|
|
|
@media (min-width: 0px) {
|
|
|
|
${contentArg}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-05-27 21:15:38 +00:00
|
|
|
export const cssForPhablet = async contentArg => {
|
|
|
|
if ((await getEnvironment()) === 'native' || (await getEnvironment()) === 'desktop') {
|
2020-05-23 15:00:01 +00:00
|
|
|
return `
|
|
|
|
@media (max-width: ${phablet}px) {
|
|
|
|
${contentArg}
|
|
|
|
}
|
|
|
|
`;
|
2020-05-27 21:15:38 +00:00
|
|
|
} else if ((await getEnvironment()) === 'phablet' || (await getEnvironment()) === 'phone') {
|
2020-05-23 15:00:01 +00:00
|
|
|
return `
|
|
|
|
@media (min-width: 0px) {
|
|
|
|
${contentArg}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-05-27 21:15:38 +00:00
|
|
|
export const cssForPhone = async contentArg => {
|
|
|
|
if ((await getEnvironment()) === 'native' || (await getEnvironment()) === 'desktop') {
|
2020-05-23 15:00:01 +00:00
|
|
|
return `
|
|
|
|
@media (max-width: ${phone}px) {
|
|
|
|
${contentArg}
|
|
|
|
}
|
|
|
|
`;
|
2020-05-27 21:15:38 +00:00
|
|
|
} else if ((await getEnvironment()) === 'phone') {
|
2020-05-23 15:00:01 +00:00
|
|
|
return `
|
|
|
|
@media (min-width: 0px) {
|
|
|
|
${contentArg}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
}
|
|
|
|
};
|