EvalueTonSavoir/client/src/components/GiftTemplate/templates/GlobalFeedbackTemplate.ts

27 lines
937 B
TypeScript
Raw Normal View History

2025-01-25 02:02:18 -05:00
import { TemplateOptions } from './types';
2025-01-26 09:33:42 -05:00
import {FormattedTextTemplate} from './TextTypeTemplate';
2024-03-29 20:08:34 -04:00
import { state } from '.';
import { theme } from '../constants';
2025-01-25 02:02:18 -05:00
import { TextFormat } from 'gift-pegjs';
2024-03-29 20:08:34 -04:00
2025-01-25 02:02:18 -05:00
type GlobalFeedbackOptions = TemplateOptions & TextFormat;
2024-03-29 20:08:34 -04:00
2025-01-25 02:02:18 -05:00
export default function GlobalFeedbackTemplate({ format, text }: GlobalFeedbackOptions): string {
2024-03-29 20:08:34 -04:00
const Container = `
position: relative;
margin-top: 1rem;
padding: 0 1rem;
background-color: ${theme(state.theme, 'beige100', 'black400')};
color: ${theme(state.theme, 'beige900', 'gray200')};
border: ${theme(state.theme, 'beige300', 'black300')} ${state.theme === 'light' ? 1 : 2}px solid;
border-radius: 6px;
box-shadow: 0px 2px 5px ${theme(state.theme, 'gray400', 'black800')};
`;
2025-01-25 02:02:18 -05:00
return (format && text)
2024-03-29 20:08:34 -04:00
? `<div style="${Container}">
2025-01-26 09:33:42 -05:00
<p>${FormattedTextTemplate({format: format, text: text})}</p>
2024-03-29 20:08:34 -04:00
</div>`
: ``;
}