Skip to content

Commit 78dfdfb

Browse files
committed
New Incubator widget : Content_Placeholder
1 parent 5265aa8 commit 78dfdfb

File tree

8 files changed

+183
-0
lines changed

8 files changed

+183
-0
lines changed

src/main/java/gwt/material/design/incubator/client/base/constants/IncubatorCssName.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,5 @@ public interface IncubatorCssName {
4646
String LABEL_PANEL = "label-panel";
4747
String JSON_TABLE = "json-table";
4848
String SINGLE_LANGUAGE = "single-language";
49+
String CONTENT_PLACEHOLDER = "content-placeholder";
4950
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* #%L
3+
* GwtMaterial
4+
* %%
5+
* Copyright (C) 2015 - 2017 GwtMaterialDesign
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
package gwt.material.design.incubator.client.placeholder;
21+
22+
import com.google.gwt.core.client.GWT;
23+
import com.google.gwt.resources.client.ClientBundle;
24+
import com.google.gwt.resources.client.TextResource;
25+
26+
public interface PlaceholderClientBundle extends ClientBundle {
27+
PlaceholderClientBundle INSTANCE = GWT.create(PlaceholderClientBundle.class);
28+
29+
@Source("resources/css/content-placeholder.min.css")
30+
TextResource contentPlaceholderCss();
31+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* #%L
3+
* GwtMaterial
4+
* %%
5+
* Copyright (C) 2015 - 2017 GwtMaterialDesign
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
package gwt.material.design.incubator.client.placeholder;
21+
22+
import com.google.gwt.core.client.GWT;
23+
import com.google.gwt.resources.client.ClientBundle;
24+
import com.google.gwt.resources.client.TextResource;
25+
26+
public interface PlaceholderDebugClientBundle extends ClientBundle {
27+
PlaceholderDebugClientBundle INSTANCE = GWT.create(PlaceholderDebugClientBundle.class);
28+
29+
@Source("resources/css/content-placeholder.css")
30+
TextResource contentPlaceholder();
31+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package gwt.material.design.incubator.client.placeholder;
2+
3+
import com.google.gwt.dom.client.Document;
4+
import gwt.material.design.client.MaterialDesignBase;
5+
import gwt.material.design.client.base.MaterialWidget;
6+
import gwt.material.design.incubator.client.AddinsIncubator;
7+
import gwt.material.design.incubator.client.base.IncubatorWidget;
8+
import gwt.material.design.incubator.client.base.constants.IncubatorCssName;
9+
import gwt.material.design.incubator.client.loadingstate.LoadingStatePanel;
10+
11+
public class PlaceholderItem extends MaterialWidget {
12+
13+
static {
14+
IncubatorWidget.showWarning(LoadingStatePanel.class);
15+
if (AddinsIncubator.isDebug()) {
16+
MaterialDesignBase.injectCss(PlaceholderDebugClientBundle.INSTANCE.contentPlaceholder());
17+
} else {
18+
MaterialDesignBase.injectCss(PlaceholderClientBundle.INSTANCE.contentPlaceholderCss());
19+
}
20+
}
21+
22+
public PlaceholderItem() {
23+
super(Document.get().createDivElement(), IncubatorCssName.CONTENT_PLACEHOLDER);
24+
}
25+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package gwt.material.design.incubator.client.placeholder;
2+
3+
import com.google.gwt.core.client.GWT;
4+
import com.google.gwt.user.client.ui.Widget;
5+
import gwt.material.design.client.base.MaterialWidget;
6+
7+
public class PlaceholderLoader {
8+
9+
private int totalItems;
10+
private MaterialWidget container;
11+
private PlaceholderRenderer renderer;
12+
13+
public PlaceholderLoader setContainer(MaterialWidget container) {
14+
this.container = container;
15+
return this;
16+
}
17+
18+
public PlaceholderLoader setRenderer(PlaceholderRenderer renderer) {
19+
this.renderer = renderer;
20+
return this;
21+
}
22+
23+
public PlaceholderLoader setTotalItems(int totalItems) {
24+
this.totalItems = totalItems;
25+
return this;
26+
}
27+
28+
public void load() {
29+
if (container != null) {
30+
if (renderer != null) {
31+
container.clear();
32+
for (int i = 0; i < totalItems; i++) {
33+
Widget widget = renderer.render();
34+
container.add(widget);
35+
}
36+
} else {
37+
GWT.log("Widget renderer is not defined");
38+
}
39+
} else {
40+
GWT.log("Container is not defined.", new IllegalStateException());
41+
}
42+
}
43+
44+
public void unload(){
45+
container.clear();
46+
}
47+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package gwt.material.design.incubator.client.placeholder;
2+
3+
import com.google.gwt.user.client.ui.Widget;
4+
5+
public interface PlaceholderRenderer {
6+
7+
Widget render();
8+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
@-webkit-keyframes placeHolderShimmer {
2+
0% {
3+
background-position: -468px 0;
4+
}
5+
100% {
6+
background-position: 468px 0;
7+
}
8+
}
9+
10+
@keyframes placeHolderShimmer {
11+
0% {
12+
background-position: -468px 0;
13+
}
14+
100% {
15+
background-position: 468px 0;
16+
}
17+
}
18+
19+
.content-placeholder {
20+
display: inline-block;
21+
-webkit-animation-duration: 1s;
22+
animation-duration: 1s;
23+
-webkit-animation-fill-mode: forwards;
24+
animation-fill-mode: forwards;
25+
-webkit-animation-iteration-count: infinite;
26+
animation-iteration-count: infinite;
27+
-webkit-animation-name: placeHolderShimmer;
28+
animation-name: placeHolderShimmer;
29+
-webkit-animation-timing-function: linear;
30+
animation-timing-function: linear;
31+
background: #f6f7f8;
32+
background: -webkit-gradient(linear, left top, right top, color-stop(8%, #eeeeee), color-stop(18%, #dddddd), color-stop(33%, #eeeeee));
33+
background: -webkit-linear-gradient(left, #eeeeee 8%, #dddddd 18%, #eeeeee 33%);
34+
background: linear-gradient(to right, #eeeeee 8%, #dddddd 18%, #eeeeee 33%);
35+
-webkit-background-size: 800px 104px;
36+
background-size: 800px 104px;
37+
height: inherit;
38+
position: relative;
39+
}

src/main/resources/gwt/material/design/incubator/client/placeholder/resources/css/content-placeholder.min.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)