package org.genericsystem.reactor.gs;

import java.util.function.Consumer;

import javafx.beans.binding.Bindings;

import org.genericsystem.reactor.Tag;
import org.genericsystem.reactor.gstag.HtmlHyperLink;
import org.genericsystem.reactor.modelproperties.SelectionDefaults;

/**
 * @author Nicolas Feybesse
 *
 */
public class GSModal extends GSDiv implements SelectionDefaults {

	public GSModal(Tag parent, Consumer<Tag> contentTagConsumer) {
		this(parent, FlexDirection.COLUMN, contentTagConsumer);
	}

	public GSModal(Tag parent, FlexDirection direction, Consumer<Tag> contentTagConsumer) {
		super(parent, direction);
		addStyleClass("modal");
		bindStyle(DISPLAY, DISPLAY, model -> Bindings.createStringBinding(() -> getSelectionProperty(model).getValue() != null ? "flex" : "none", getSelectionProperty(model)));

		new GSDiv(this, FlexDirection.COLUMN) {
			{
				addStyle("max-width", "40%");
				addStyleClass("modal-content");

				new GSDiv(this, FlexDirection.COLUMN) {
					{
						new HtmlHyperLink(this) {
							{
								addStyleClass("close");
								setText("×");
								bindAction(model -> getSelectionProperty(model).setValue(null));
							}
						};
						select__(model -> getSelectionProperty(model));
						contentTagConsumer.accept(this);
					}
				};
			}
		};
	}
}

@@ -73,47 +73,8 @@
 r;%0A%0A
-import javafx.beans.binding.Bindings;%0A%0A
 impo
@@ -230,16 +230,55 @@
 aults;%0A%0A
+import javafx.beans.binding.Bindings;%0A%0A
 /**%0A * @
@@ -932,16 +932,131 @@
 ntent%22);
+%0A%09%09%09%09addStyle(%22padding%22, %2210px%22);%0A%09%09%09%09addStyle(%22border-radius%22, %2210px%22);%0A%09%09%09%09addStyle(%22background-color%22, %22white%22);
 %0A%0A%09%09%09%09ne

Improve css