|
Метки: очистка ручная отмена |
| (не показано 28 промежуточных версий этого же участника) |
| Строка 1: |
Строка 1: |
| local p = {}
| |
|
| |
|
| function p.card(frame)
| |
| local args = frame:getParent().args
| |
| local title = args["Название"] or "Без названия"
| |
| local ingredients = args["Ингредиенты"] or ""
| |
| local result = args["Результат"] or ""
| |
| local effects = args["Эффекты"] or ""
| |
| local effectsDesc = args["ОписаниеЭффектов"] or ""
| |
|
| |
| local borderColor = args["ЦветРамки"] or "#ccc"
| |
| local backgroundColor = args["ЦветФона"] or "#f9f9f9"
| |
|
| |
| local function listBlock(text)
| |
| local items = {}
| |
| for item in mw.text.gsplit(text, ";") do
| |
| table.insert(items, "<div>" .. mw.text.trim(item) .. "</div>")
| |
| end
| |
| return table.concat(items, "\n")
| |
| end
| |
|
| |
| local function listUL(text)
| |
| local items = {}
| |
| for item in mw.text.gsplit(text, ";") do
| |
| table.insert(items, "<li>" .. mw.text.trim(item) .. "</li>")
| |
| end
| |
| return table.concat(items, "\n")
| |
| end
| |
|
| |
| local html = {}
| |
|
| |
| -- Карточка с классом для сетки
| |
| table.insert(html, '<div class="alchemy-recipe-card" style="border: 2px solid ' .. borderColor .. '; padding: 1em; border-radius: 8px; background: ' .. backgroundColor .. '; box-sizing: border-box;">')
| |
|
| |
| table.insert(html, '<h3 style="margin-top:0; text-align:center; font-size:1.1em;">' .. title .. '</h3>')
| |
|
| |
| -- Флекс с ингредиентами, смешать, результат
| |
| table.insert(html, '<div style="display: flex; text-align: center; align-items: stretch; font-size: 0.9em;">')
| |
|
| |
| table.insert(html, '<div style="flex: 1; display: flex; flex-direction: column; justify-content: center; border-right: 1px solid #aaa; padding-right: 0.5em;">')
| |
| table.insert(html, listBlock(ingredients))
| |
| table.insert(html, '</div>')
| |
|
| |
| table.insert(html, '<div style="flex: 0 0 80px; display: flex; align-items: center; justify-content: center; font-weight:bold;">СМЕШАТЬ</div>')
| |
|
| |
| table.insert(html, '<div style="flex: 1; display: flex; flex-direction: column; justify-content: center; border-left: 1px solid #aaa; padding-left: 0.5em;">')
| |
| table.insert(html, listBlock(result))
| |
| table.insert(html, '</div>')
| |
|
| |
| table.insert(html, '</div>')
| |
|
| |
| -- Эффекты список
| |
| if effects ~= "" then
| |
| table.insert(html, '<hr style="margin: 0.5em 0;"><b>Эффекты:</b><ul style="margin: 0.3em 0 0 1.2em; padding: 0;">')
| |
| table.insert(html, listUL(effects))
| |
| table.insert(html, '</ul>')
| |
| end
| |
|
| |
| -- Описание эффектов (курсивом)
| |
| if effectsDesc ~= "" then
| |
| table.insert(html, '<div style="margin-top: 0.5em; font-style: italic; color: #555; font-size: 0.85em;">' .. mw.text.trim(effectsDesc) .. '</div>')
| |
| end
| |
|
| |
| table.insert(html, '</div>')
| |
|
| |
| return table.concat(html, "\n")
| |
| end
| |
|
| |
| return p
| |