All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.nasdanika.html.bootstrap.impl.SpacingImpl Maven / Gradle / Ivy

package org.nasdanika.html.bootstrap.impl;

import org.nasdanika.html.bootstrap.BootstrapElement;
import org.nasdanika.html.bootstrap.Breakpoint;
import org.nasdanika.html.bootstrap.Size;
import org.nasdanika.html.bootstrap.Spacing;

public class SpacingImpl> implements Spacing {
	
	private B bootstrapElement;
	private String prefix;

	SpacingImpl(B bootstrapElement, String prefix) {
		this.bootstrapElement = bootstrapElement;
		this.prefix = prefix;
	}

	@Override
	public B toBootstrapElement() {
		return bootstrapElement;
	}
	
	private void suffix(String suffix) {
		bootstrapElement.toHTMLElement().addClass(prefix+suffix);
	}

	@Override
	public Spacing top(Breakpoint breakpoint, Size size) {
		suffix(breakpoint.size("t", size));
		return this;
	}

	@Override
	public Spacing bottom(Breakpoint breakpoint, Size size) {
		suffix(breakpoint.size("b", size));
		return this;
	}

	@Override
	public Spacing left(Breakpoint breakpoint, Size size) {
		suffix(breakpoint.size("l", size));
		return this;
	}

	@Override
	public Spacing right(Breakpoint breakpoint, Size size) {
		suffix(breakpoint.size("r", size));
		return this;
	}

	@Override
	public Spacing x(Breakpoint breakpoint, Size size) {
		suffix(breakpoint.size("x", size));
		return this;
	}

	@Override
	public Spacing y(Breakpoint breakpoint, Size size) {
		suffix(breakpoint.size("y", size));
		return this;
	}

	@Override
	public Spacing all(Breakpoint breakpoint, Size size) {
		bootstrapElement.toHTMLElement().addClass(breakpoint.size(prefix, size));
		// TODO Auto-generated method stub
		return this;
	}

}