001package gwt.material.design.client.ui; 002 003/* 004 * #%L 005 * GwtMaterial 006 * %% 007 * Copyright (C) 2015 GwtMaterialDesign 008 * %% 009 * Licensed under the Apache License, Version 2.0 (the "License"); 010 * you may not use this file except in compliance with the License. 011 * You may obtain a copy of the License at 012 * 013 * http://www.apache.org/licenses/LICENSE-2.0 014 * 015 * Unless required by applicable law or agreed to in writing, software 016 * distributed under the License is distributed on an "AS IS" BASIS, 017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 018 * See the License for the specific language governing permissions and 019 * limitations under the License. 020 * #L% 021 */ 022 023import gwt.material.design.client.base.HasTitle; 024import gwt.material.design.client.constants.HeadingSize; 025import gwt.material.design.client.ui.html.Div; 026import gwt.material.design.client.ui.html.Heading; 027import gwt.material.design.client.ui.html.Paragraph; 028 029import com.google.gwt.dom.client.Style.Unit; 030 031//@formatter:off 032/** 033 * Title is a component that will easily add Title and description widgets 034 * 035 * <p> 036 * <h3>UiBinder Usage:</h3> 037 * <pre> 038 * {@code 039 * <m:MaterialTitle title="I love Material Design" description="This is sample description" /> 040 * } 041 * </pre> 042 * </p> 043 * 044 * @author kevzlou7979 045 * @author Ben Dol 046 */ 047//@formatter:on 048public class MaterialTitle extends Div implements HasTitle { 049 050 Heading header = new Heading(HeadingSize.H4); 051 Paragraph paragraph = new Paragraph(); 052 053 public MaterialTitle() { 054 header.setFontWeight(300); 055 header.getElement().getStyle().setMarginTop(60, Unit.PX); 056 add(header); 057 add(paragraph); 058 } 059 060 public MaterialTitle(String title, String description) { 061 this(); 062 setTitle(title); 063 setDescription(description); 064 } 065 066 public MaterialTitle(String title) { 067 this(); 068 setTitle(title); 069 } 070 071 @Override 072 public void setDescription(String description) { 073 paragraph.setText(description); 074 } 075 076 @Override 077 public void setTitle(String title) { 078 header.getElement().setInnerHTML(title); 079 } 080}