Template:Sandbox/Drusna/Crafting/doc
An updated version of Template:Grid/Crafting with improved usability. DON'T USE THIS TEMPLATE - still in the development phase, subject to change entirely without notice.
Usage
See Template:Grid/Crafting for the original documentation.
{{Sandbox/Drusna/Crafting
|A1=c1r1 |A1N=num |A1-image=image (with extension) |A1-link=link |A1_name
|A2=c1r2 |A2N=num |A2-image=image (with extension) |A2-link=link |A2_name
|A3=c1r3 |A3N=num |A3-image=image (with extension) |A3-link=link |A3_name
|B1=c2r1 |B1N=num |B1-image=image (with extension) |B1-link=link |B1_name
|B2=c2r2 |B2N=num |B2-image=image (with extension) |B2-link=link |B2_name
|B3=c2r3 |B3N=num |B3-image=image (with extension) |B3-link=link |B3_name
|C1=c3r1 |C1N=num |C1-image=image (with extension) |C1-link=link |C1_name
|C2=c4r2 |C2N=num |C2-image=image (with extension) |C2-link=link |C2_name
|C3=c3r3 |C3N=num |C3-image=image (with extension) |C3-link=link |C3_name
|Output=out |OA=num |Output-link=link |Output_name=name
|NoBreak=y
}}
Features
Backwards compatibility
The new template should have the same layout properties as the old template when it's used without any newly-added features. This ensures that the >1500 pages which use Template:Grid/Crafting don't have their layout changed by the update.
NoBreak not used
|
NoBreak=y
| |||
|---|---|---|---|---|
| Old | New | Old | New | |
float not used
|
Text before
Text after |
Text before
Text after |
Text before
Text after |
Text before
Text after |
float=left
|
Text before
Text after |
Text before
Text after |
Text before
Text after |
Text before
Text after |
float=right
|
Text before
Text after |
Text before
Text after |
Text before
Text after |
Text before
Text after |
float=none
|
Text before
Text after |
Text before
Text after |
Text before
Text after |
Text before
Text after |
Additionally, Template:Crafting should have its layout unaffected.
| Old | New | ||||||||
|---|---|---|---|---|---|---|---|---|---|
|
|
Optional output slot
The new template allows you to only display a recipe's inputs by leaving the Output parameter empty. This is useful when the recipe's output is implied by context clues, and you want to save space or avoid redundancy.
Old method:
| Ingredients | Crafting Recipe |
|---|---|
| 1x Knife or Shears 8x Pelt (Small) OR 5x Pelt (Medium) OR 3x Pelt (Large) OR 1x Pelt (Huge) |
New method:
| Output | Crafting Recipes |
|---|---|
Fur coat |
New layout options
If any of the new parameters are used, then the float and NoBreak parameters are ignored.
halign
halign behaves similarly to MediaWiki images' horizontal alignment option (see [1]), and allows center alignment. A margin is automatically added between the template and nearby text.
| Template | Image | |
|---|---|---|
| halign=none | Text before the template.
Text after the template. |
Text before an image.
![]() Text after an image. |
| halign=center | Text before the template.
Text after the template. |
Text before an image.
![]() Text after an image. |
| halign=left | Text before the template.
Text after the template. |
Text before an image.
![]() Text after an image. |
| halign=right | Text before the template.
Text after the template. |
Text before an image.
![]() Text after an image. |
| Default | Text before the template.
Text after the template. |
Text before an image.
|
margin
Displaying multiple recipes side-by-side is a common use case. However, this is surprisingly difficult with the old template, causing different wiki pages to have different ways of doing this.
Option 1: use NoBreak and allow divs to all float left. For example, Plaster#Crafting_Plaster_Variants
- No additional HTML/CSS, but we want more space between grids.
- On mobile, the 3rd grid wraps to the next line, which creates uneven formatting.
- Last recipe must have an added linebreak if there is any text following it, or else the templates float left of the following text.
Option 2: Put different recipes in different cells of a table. For example, Guide:Prepare_for_Winter#Warmth
- No additional HTML/CSS, but using a table limits formatting options.
- Space between grids is determined by table padding.
- Looks the same on mobile as on desktop; users scroll horizontally to see all the recipes.
Option 3: Wrap recipes in <div style="display:flex">...</div>. For example, Axe#Creation.
- To add space between recipes, each one can be wrapped in another div with
style="margin-right:10px", as in Knife#Creation. - Alternatively, you can use
float=noneandNoBreak=yon each template and add between them, as is done elsewhere on this page - Similarly, you can use
<ul>and<li>elements, as in Fur_clothing_set - Allows precise control, but requires HTML/CSS knowledge
- Will be implemented differently on every page, leading to inconsistency across the wiki
Option 4: Use the new margin parameter.
- Achieves the same thing as the flexbox solution, but without requiring HTML.
Additional text for example purposes
Fixes
Background image
The old template's background crafting grid image (
) has a number of issues:
- The gap between columns 2 and 3 is 1 pixel too wide; same for rows 2 and 3
- The top margin is 1px larger than the other margins
- The image gets resized from 189px to 174px by the template, which introduces artifacts
The new template uses a new image (
and
) which solves these issues, and reduces the margin by 5px.
Rendering items and numbers
Issues with the old template:
- Elements are wrapped in
<p>blocks, which causes items and numbers to be misaligned on mobile or with different font sizes - Numbers in a crafting grid inside a collapsible table don't render at all on mobile due to a MediaWiki bug involving lazy-loaded images
- Hovering your mouse over the 10s place of a 1-digit number causes the link and hover text to disappear
The new template fixes these issues, and:
- Matches the in-game font and improves readability
- Matches the in-game size of items
- Can render arbitrary numbers
| New | Old |
|---|---|
Tests
Placeholder puppy
Link, name, image tests
The hover-text for an item should be determined using the name parameter if it's used, or the linked page's title otherwise.
Number rendering tests
- Numbers should look the same regardless of sub-pixel positioning of the template
- There should be a 1 pixel gap between the number and the bottom/right of the grid cell
- Numbers should have a consistent 1 pixel outline and no blurry edges
| Left | Center | Right | |
|---|---|---|---|
Try resizing this cell using the handle in the lower right corner.
| |||
Try resizing this cell using the handle in the lower right corner.
|
|||


