@inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.LinkViewModel>
@using Page = Dynamicweb.Content.Page

@functions 
{
	private string GetFontStack()
	{
		return "font-family:initial,Arial,Helvetica Neue,Helvetica,sans-serif;";
	}

	private string GetTableReset()
	{
		return "border-collapse:separate;border-spacing:0;border:0;margin:0;outline:0;padding:0;";
	}
}

@{ 
	var backgroundColor = GetViewParameter("backgroundColor");
	var foregroundColor = GetViewParameter("foregroundColor");
	var borderColor = GetViewParameterString("borderColor");
	var align = GetViewParameterString("align");
	var title = GetViewParameterString("title");
	var link = Model.Url;
}

<table border="0" cellpadding="0" cellspacing="0" style="border-collapse:separate;mso-table-lspace:0pt;mso-table-rspace:0pt;mso-line-height-rule:exactly;@GetTableReset()width:100%;box-sizing:border-box;min-width:100% !important;" width="100%">
	<tbody>
		<tr style="@GetTableReset()">
			<td align="@align" style="@GetTableReset()vertical-align:top;" valign="top">
				<!--[if mso]>
				<table border="0" cellspacing="0" cellpadding="0">
					<tr style="@GetTableReset()">
						<td align="@align" style="@GetTableReset()background-color:@(backgroundColor);">
							<a href="@link" target="_blank" style="@GetFontStack()line-height:16px;font-size:16px;text-decoration:none;bold;padding-top:14px;padding-right:24px;padding-bottom:14px;padding-left:24px;border:1px solid @(borderColor);display:inline-block;color:@foregroundColor;">@title</a>
						</td>
					</tr>
				</table>
				<![endif]-->

				<table border="0" cellpadding="0" cellspacing="0" style="mso-hide:all;@GetTableReset()">
					<tr style="@GetTableReset()">
						<td align="@align" valign="middle" bgcolor="@(backgroundColor)" style="@GetFontStack()line-height:16px;font-size:16px;padding-top:14px;padding-right:24px;padding-bottom:14px;padding-left:24px;border:1px solid @(borderColor)">
							<a href="@link" target="_blank" style="text-decoration:none;color:@(foregroundColor);@GetFontStack()">
								<span style="color:@(foregroundColor);@GetFontStack()">@title</span>
							</a>
						</td>
					</tr>
				</table>
			</td>
		</tr>
	</tbody>
</table>
