Vue Mazeletter background - css

I am trying to use Mazeletter to create a background for every page on an app that I am building. However, I haven't done anything like this before and I would like some help with this. I have a basic test component which works as the background, and I can successfully place elements over it.
However, I want to make this a little more dynamic. One the text should be dynamic (i.e. passed in via props) and there should be enough text to have the background for as much content is present on the page (this would also be dynamic).
Here is the test component that I am currently working with:
<template>
<div id="mz-background">
<p class="mz-text">ThisIsATestThisIsATestThisIsATestThisIsATest</p>
<p class="mz-text">ThisIsATestThisIsATestThisIsATestThisIsATest</p>
<p class="mz-text">ThisIsATestThisIsATestThisIsATestThisIsATest</p>
<p class="mz-text">ThisIsATestThisIsATestThisIsATestThisIsATest</p>
<p class="mz-text">ThisIsATestThisIsATestThisIsATestThisIsATest</p>
<p class="mz-text">ThisIsATestThisIsATestThisIsATestThisIsATest</p>
<p class="mz-text">ThisIsATestThisIsATestThisIsATestThisIsATest</p>
<p class="mz-text">ThisIsATestThisIsATestThisIsATestThisIsATest</p>
<p class="mz-text">ThisIsATestThisIsATestThisIsATestThisIsATest</p>
<p class="mz-text">ThisIsATestThisIsATestThisIsATestThisIsATest</p>
<p class="mz-text">ThisIsATestThisIsATestThisIsATestThisIsATest</p>
<p class="mz-text">ThisIsATestThisIsATestThisIsATestThisIsATest</p>
<p class="mz-text">ThisIsATestThisIsATestThisIsATestThisIsATest</p>
<p class="mz-text">ThisIsATestThisIsATestThisIsATestThisIsATest</p>
</div>
</template>
<script>
export default {
name: "UnderworldPattern",
};
</script>
<style scoped>
#mz-background {
z-index: 0;
position: fixed;
overflow: hidden;
width: 100vw;
height: 100vh;
}
.mz-text {
line-height: 89.5px;
font-family: "mazeletter-underworld"; // imported in project css
font-size: 90px;
z-index: 1;
color: #000000;
user-select: none;
text-align: left;
letter-spacing: -0.409091px;
}
</style>
If someone could help me out in making this more dynamic I would be very grateful
Thanks for your time

Maybe something like following:
Define long set of chars and set overflow: hidden; on #mz-background.
Add listener on created hook, to detect window resize and call method to calculate nr of lines depending on ˙font-size˙. Then in template loop over calculated nr of lines.(rough solution)
export default {
name: "UnderworldPattern",
data() {
return {
textToShow: 'ThisIsATestThisIsATestThisIsATestThisIsATestThisIsATestThisIsATestThisIsATestThisIsATest',
nrOfLines: 0
}
},
methods: {
getNrOfLines() {
this.nrOfLines = parseInt(document.documentElement.clientHeight / 90)
}
},
mounted() {
this.getNrOfLines()
},
created() {
window.addEventListener("resize", this.getNrOfLines);
},
unmounted() {
window.removeEventListener("resize", this.getNrOfLines);
},
};
#mz-background {
z-index: 0;
position: fixed;
overflow: hidden;
width: 100vw;
height: 100vh;
}
.mz-text {
line-height: 89.5px;
font-family: "mazeletter-underworld"; // imported in project css
font-size: 90px;
z-index: 1;
color: black;
user-select: none;
text-align: left;
letter-spacing: -0.409091px;
overflow: hidden;
margin: 0;
}
<div id="app">
<template>
<div id="mz-background">
<p class="mz-text" v-for="index in nrOfLines" :key="index">{{ textToShow }}</p>
</div>
</template>
</div>

Related

Position element in relation to a list element

I'm trying to make a pop-up options box appear next to each one of the elements of a file list. This window show the options available for that files.
I'm using an onClick function that toggle classes between one hidden and the other visible. My problem is that the box is placed always in the same place, despite the file you click, so it seems like you are always opening the options from the first file.
The React code:
return (
<div className='file-row'>
<div className='file-row-1'>
<div className='checkbox-iconFile-container'>
<input className='checkbox-folder' type="checkbox"/>
<p id={props.id} className='file-name'><img className='resourceIcon'alt='tipo de documento' src={resourceIcon}></img>{newStr}</p>
</div>
<p className='file-date'>{date}</p>
<p className='groups-file-text'>UBIP,...</p>
</div>
<div className='div-hidden-options'>
<ModalResources></ModalResources>
<div className='moreInfo-dots-container' onClick={showFileOptions}>
<img className='moreInfo-dots' alt='Opciones' src={dots}></img>
</div>
<div id='file-options' className='div-file-options-hidden'>
<p>Modificar título</p>
<p>Modificar archivo</p>
<p>Mover recurso</p>
<p>Eliminar recurso</p>
</div>
</div>
</div>
)
The showFileOptions function :
function showFileOptions () {
let optionsDiv = document.getElementById('file-options');
optionsDiv.classList.toggle('div-file-options-show');
}
And the CSS:
.div-hidden-options {
width: 15%;
display: flex;
flex-direction: row;
justify-content: space-between;
}
.div-file-options-hidden {
visibility: hidden;
position: absolute;
}
.div-file-options-show {
visibility: visible;
position: absolute;
margin-left: 15%;
background-color: white;
border: 1px solid #DDDDDD;
padding: 5px;
border-radius: 5px;
margin-top: -36px;
}
And an image of the position that the box takes regardless of the file we click:
And this is the desirable behaviour of the box when the second file is clicked:

Is there a way to style an element in React using the ID without using className?

I am converting an old website into React, and do not want to have to change all the CSS files that were previously coded. A lot of elements have their styles set currently by using an id. Is there a way to get className={styles["#topBar"]} to set the style correctly without having to delete the # and replacing it with a . in the CSS folder?
Since you are using CSS Modules you need to access the styles slightly differently. You need to import styles from 'Component.module.css'; and then declare your styles by referencing this imported object styles.MyClass or in your case since you have hyphens you need to use bracket notation styles["top-bar"]
Here is a working sandbox
//MyComponent.js
import styles from "./MyComponent.module.css";
export default function MyComponent() {
return (
<div id={styles["top-bar"]}>
<h2>My Component</h2>
<InnerComponent id="inner" />
</div>
);
}
function InnerComponent({ id }) {
return (
<div id={styles[id]}>
<h3>Inner Component</h3>
<p id={styles.para}>Styled Paragraph</p>
</div>
);
}
//MyComponent.module.css
#top-bar {
width: 90vw;
margin: 1rem auto;
padding: 1rem;
text-align: center;
background-color: LightPink;
}
#inner {
background-color: LightBlue;
text-align: left;
}
#para {
color: red;
}
Here's a quick snippet showing it working with IDs.
function MyComponent() {
return (
<div id="top-bar">
<h2>My Component</h2>
<InnerComponent id="inner" />
</div>
)
}
function InnerComponent({id}) {
return (
<div id={id}>
<h3>Inner Component</h3>
</div>
)
}
ReactDOM.render(<MyComponent />, document.getElementById('App'));
#top-bar {
width: 90vw;
margin: 1rem auto;
padding: 1rem;
text-align:center;
background-color: LightPink;
}
#inner {
background-color: LightBlue;
text-align: left;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>
<div id="App"></div>

Can't find div for styling (tranform zoom) in javascript script tag in shadow dom of polymer 2.0 element

I am creating a polymer 2.0 PWA / Website. I have a problem with accessing a div container (I wish to zoom in and zoom out the div based on a user input).
In shadow dom with template dom if I am not able to get the element in Javascript so that on user action (like button click or slider) movement I can zoom the div.
I tried document getElementsByClassName, shadowroot search. I can see in shadow dom that this div is present. just not able to access it in javascript function in Polymer.
var ele = document.getElementsByClassName('containerMap')[0]; //
returns null in console can't find the element in shadow Dom
var el = this.shadowRoot.querySelector('someid'); // returns
null in console also tried '#someid' still null
console.log('shadowRoot el = '+JSON.stringify(el));
var elx = document.getElementById('someid'); // returns null in
console
console.log('shadowRoot el = '+JSON.stringify(elx));
//var el = this.$.someid; // does not find the element
// tried this.$['#someid'] this.$$('#someid') // does not work
console.log(el);
Here's the full code (removed few unwanted code elements so that focus is on the problem in hand)
MyApp.html
<link rel="lazy-import" href="epicsprint-page.html">
<dom-module id="my-app">
<template is="dom-bind">
<style>
....
</style>
....
<app-header-layout >
<div style="float:left; width:100%;">
<div style="float:left; width:10%;">
<paper-icon-button id="menuElement" icon="icons:menu" drawer-toggle halign="left"></paper-icon-button>
</div>
</div>
<div fit class="content">
<!-- IRON PAGES MAIN CONTENT -->
<iron-pages
selected="[[page]]"
attr-for-selected="name"
fallback-selection="not-found-404"
role="main">
<epicsprint-page name="epicsprint-page" user="{{user}}"
signedin="{{signedIn}}" statusknown="{{statusKnown}}" >
</epicsprint-page>
.....
</div>
</app-header-layout>
</app-drawer-layout>
</template>
</template>
<script>
</script>
...
window.customElements.define(MyApp.is, MyApp);
</script>
</dom-module>
Element: epicspring-page.html
<dom-module id="epicsprint-page">
<template is="dom-bind">
<style include="shared-styles">
:host {
padding: 10px;
font-family:'Fira Sans', sans-serif;
}
a paper-button,
a:hover paper-button,
a:link paper-button,
a:active paper-button,
a:visited paper-button {
width: 20%;
height: 35px;
}
.page { overflow:auto; width: 90%; height: 100%; }
.containerMap { width:100%; background: grey; }
.error-content{
width: 80wh;
height: 300px;
overflow: auto;
align-items: center;
}
/*************/
.board­__sprint {
/*background: #5ba4cf;*/
position: absolute;
left: auto;
padding: 20px;
overflow-x: auto;
white-space: nowrap;
}
.list {
display: inline-block;
vertical-align: top;
/*background: #d2d7e5;*/
width: 300px;
padding: 1px;
}
.list-content {
max-height: 80%;
overflow-y: auto;
padding-right: 5px;
/*margin-right: -5px;*/
margin-bottom: 20px;
padding-bottom: 60px;
}
.list-name {
padding: 10px;
border: none;
background: transparent;
}
.add-ticket {
background: linear-gradient(to bottom, #61bd4f 0, #5aac44
100%);
color: white;
font-weight: bold;
border: none;
padding: 10px;
}
.ticket {
/*background: white;*/
flex: 0 0 auto;
margin: 5px;
width: 200px;
height: 70px;
align-items: center;
white-space: normal;
}
.ticket-title {
width: 100%;
padding: 20px;
}
/*********/
</style>
<iron-ajax
id="getEpicSprintMap"
method="GET"
url="{{url}}"
handle-as="json"
content-type="application/json"
on-response="handleResponseGetEpicSprintMap"
on-error="handleErrorGetEpicSprintMap"
last-response="{{mapsData}}"
last-error="{{lastError}}">
</iron-ajax>
<div style="width: 100%">
<div style="float:left;">
<div><h5></h5></div>
<paper-icon-button src="../images/icons/help-icon-png.png"
on-tap="showHelpDialog"></paper-icon-button>
</div>
<div style="float:right;">
<div><h5></h5></div>
<paper-icon-button src="../images/icons/support-icon-png.png"
on-tap="showHelpDialog"></paper-icon-button>
</div>
</div>
<template is="dom-if" if="[[signedin]]">
<template is="dom-if" if="[[mapsData.successFlag]]">
<div style="float: center;">
<h5 style="color: white; font-size: 12px; text-
align:left;"> </h5>
</div>
<div style="float: center; display: flex">
<iron-image src="../images/logo.png" preload
sizing="contain"
on-tap="reloadEpics" style="width:200px; height:200px;
margin:auto;" ></iron-image>
</div>
<div style="float: center;">
<h1 style="color: white" class="launchAmount">Epics &
Sprints</h1>
<h2 style="color: white" class="launchAmount">Number of
sprints that an Epic spans</h2>
</div>
<input id="test" min="1" max="1000" value='1000' step="1"
onchange="showVal(this.value)" type="range"/>
<div class="containerMap" id="someid">
<div class="page">
<div class="content">
<div class="board­__sprint">
<template is="dom-repeat" items="{{mapsData.data}}"
as="row">
<div class="list">
<div class="list­-content">
<div style="text-align: center;">
<iron-image class=""
src="../images/icons/epic-icon-png.png"
preload
sizing="contain"
style="width:50px; height:50px; margin-
left: 50px;" ></iron-image>
</div>
<div style="text-align: center;">
<h3 class="sprintTitle" style="color: white; font-
size: 15px;background: black; padding: 10px; margin-top: 5px;">
<b>Epic: </b>[[row.key]]
</h3>
<h3 class="sprintTitle" style="color: white; font-
size: 15px;background: black; padding: 10px; margin-top: 5px;">
[[row.title]]
</h3>
</div>
<template is="dom-repeat" items="{{row.sprint}}"
as="sprint">
<div class="ticket">
<paper-card style="float:center; width: 95%"
class$="{{_computedCardColorStories()}}">
<div style="width: 100%;">
<div style="float:left; width: 10%"
style$="{{getRandomInt(0, 20)}}">
<h7> </h7>
</div>
<div style="float:left; width: 90%; text-
align: center; padding: 10px;">
<h7 style="color: black; font-size:
18px; text-align:center;">[[sprint]]</h7>
</div>
</div>
</paper-card>
</div>
</template>
</div>
</div>
</template>
</div>
</div>
</div>
</div>
</template>
</template>
</template>
</template>
<script>
/**
* #polymer
* #extends HTMLElement
*/
class EpicSprintMapPage extends Polymer.Element {
static get is() { return 'epicsprint-page'; }
constructor() {
super();
}
ready() {
super.ready();
}
static get properties() {
return {
user: { type: Object, notify: true, readOnly: false, observer: '_userChanged' },
signedin: { type: Boolean, notify: true, readOnly: false, observer: '_signedinChanged' },
statusKnown: { type: Boolean, notify: true, readOnly: false, observer: '_statusChanged' },
localSettings : { type: Object, notify: true, readOnly: false },
mapsData: { type: Object, notify: true },
filterFromDate : { type: String, notify: true },
filterToDate: { type: String, notify: true },
defaultSprintVelocity: { type: Number, value: 0, notify: true },
zoomVal: { type: Number, value: 100, notify: true },
}
};
_userChanged(user){
this.user = user;
}
_signedinChanged(signedin){
this.signedin = signedin;
}
_statusChanged(statusKnown){
this.statusKnown = statusKnown;
}
showVal()
{
var zoomScale = Number(this.zoomVal)/100;
console.log('zoomScale = '+zoomScale);
var ele = document.getElementsByClassName('containerMap')[0]; // returns null in console can't find the element in shadow Dom
var el = this.shadowRoot.querySelector('someid'); // returns null in console also tried '#someid' still null
console.log('shadowRoot el = '+JSON.stringify(el));
var elx = document.getElementById('someid'); // returns null in console
console.log('shadowRoot el = '+JSON.stringify(elx));
//var el = this.$.someid; // doesn't find the element
// tried this.$['#someid'] this.$$('#someid')
console.log(el);
transformOrigin = [0,0];
el = el || instance.getContainer();
var p = ["webkit", "moz", "ms", "o"],
s = "scale(" + zoomScale + ")",
oString = (transformOrigin[0] * 100) + "% " + (transformOrigin[1] * 100) + "%";
for (var i = 0; i < p.length; i++) {
el.style[p[i] + "Transform"] = s;
el.style[p[i] + "TransformOrigin"] = oString;
}
el.style["transform"] = s;
el.style["transformOrigin"] = oString;
}
}//end Polymer
window.customElements.define(EpicSprintMapPage.is, EpicSprintMapPage);
</script>
</dom-module>
I am expecting I can find the element in shadow dom and be able to style the element and mimick zoom in out functionality by transforming the div.
I am not sure how to get the element and what syntax it should be.
Try to remove :
<template is="dom-bind">
...
</template>
You can use dom-bind template in index.html in order to binding without to defining new custome element. Then you can select your div element with this.shadowRoot...
For more information about dom-bind
EDİT
As there is some variable which I don't know the values, But keep in your mind that if dom-if statement is false then its content does not render. So, you can not access any element inside.

Change CSS with AngularJS [duplicate]

Right now I have a background image URL hard-coded into CSS. I'd like to dynamically choose a background image using logic in AngularJS. Here is what I currently have:
HTML
<div class="offer-detail-image-div"><div>
CSS
.offer-detail-image-div {
position: relative;
display: block;
overflow: hidden;
max-width: 800px;
min-height: 450px;
min-width: 700px;
margin-right: auto;
margin-left: auto;
padding-right: 25px;
padding-left: 25px;
-webkit-box-flex: 1;
-webkit-flex: 1;
-ms-flex: 1;
flex: 1;
border-radius: 5px;
background-image: url('/assets/images/118k2d049mjbql83.jpg');
background-position: 0px 0px;
background-size: cover;
background-repeat: no-repeat;
}
As you can see, the background image in the CSS references a specific file location. I want to be able to programmatically determine the location of the image URL. I really don't know where to begin. I do not know JQuery. Thank you.
You can use ng-style to dynamically change a CSS class property using AngularJS.
Hope this ng-style example will help you to understand the concept at least.
More information for ngStyle
var myApp = angular.module('myApp', []);
myApp.controller("myAppCtrl", ["$scope", function($scope) {
$scope.colors = ['#C1D786', '#BF3978', '#15A0C6', '#9A2BC3'];
$scope.style = function(value) {
return { "background-color": value };
}
}]);
ul{
list-style-type: none;
color: #fff;
}
li{
padding: 10px;
text-align: center;
}
.original{
background-color: red;
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<body ng-app="myApp">
<div ng-controller="myAppCtrl">
<div class="container">
<div class="row">
<div class="span12">
<ul>
<li ng-repeat="color in colors">
<h4 class="original" ng-style="style(color)"> {{ color }}</h4>
</li>
</ul>
</div>
</div>
</div>
</div>
</body>
Edit-1
You can change the background-image: URL by following way.
$scope.style = function(value) {
return { 'background-image': 'url(' + value+')' };
}
You can use ng-class : documation.
If you want to do it in your directive check directive - attr : attr.
You can use [ngStyle] directly. It's a map, so you can directly address one of its elements like so: [ngStyle.CSS_PROPERTY_NAME]
For example:
<div class="offer-detail-image-div"
[ngStyle.background-image]="'url(' + backgroundSrc + ')'">Hello World!</div>
Also, for serving assets, Angular has the bypassSecurityTrustStyle utility function that can come in handy when serving up assets dynamically.
enter the size in textbox you can see box changes height and width
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<body>
<p>Change the value of the input field:</p>
<div ng-app="" >
<input ng-model="myCol" type="textbox">
<div style="background-color:red; width:{{myCol}}px; height:{{myCol}}px;"> </div>
</div>
</body>
</html>

How to use Css to make CellList flow Horizontally rather than Vertically? (GWT & CSS)

I have a need to use a CellList that flows horizontally, like this:
This is traditional celllist (showing vertically)
Page
1
2
3
....
I want it to show horizontally like this:
Page 1 2 3 ......
I found a solution, but some people said that this solution is not so good cos it modifies the html tag (by replacing all <div> to <span>) of the Widget.
public class HorizontalCellList<T> extends CellList<T> {
public HorizontalCellList(Cell<T> cell) {
super(cell);
}
#Override
protected void renderRowValues(
SafeHtmlBuilder sb, List<T> values, int start, SelectionModel<? super T> selectionModel) {
SafeHtmlBuilder filteredSB = new SafeHtmlBuilder();
super.renderRowValues(filteredSB, values, start, selectionModel);
SafeHtml safeHtml = filteredSB.toSafeHtml();
String filtered = safeHtml.asString().replaceAll("<div", "<span").replaceAll("div>","span>");
sb.append(SafeHtmlUtils.fromTrustedString(filtered));
}
}
Then they suggest me to use Css to achieve the same result. I tried but none of them works.
.horizontalCellList { display: inline; } --> it doesn't work
.horizontalCellList { display: inline; float:left; } --> it doesn't work either
myCellList.getElement().getStyle().setDisplay(Display.INLINE_BLOCK); --> doesn't work
myCellList.getElement().getElementsByTagName("li").getItem(i).getStyle().setDisplay(Display.INLINE);also doesn't work
For people who do not know GWT but know CSS/Html, then here is the Html code of CellList, i don't see any <span> there, they only have <div>. The trick here is how to make all the <div> turn to <span> by JUST using CSS.
<div class="GNOXVT5BEB" __gwtcellbasedwidgetimpldispatchingblur="true" __gwtcellbasedwidgetimpldispatchingfocus="true">
<div></div>
<div>
<div aria-hidden="true" style="width: 100%; height: 100%; padding: 0px; margin: 0px; display: none;">
<div aria-hidden="true" style="width: 100%; height: 100%; display: none;"></div>
</div>
<div aria-hidden="true" style="width: 100%; height: 100%; padding: 0px; margin: 0px; display: none;">
<div aria-hidden="true" style="width: 100%; height: 100%; display: none;">
</div>
</div>
</div>
</div>
Can anyone provide a good solution?
Based on what Thomas suggested, this is a complete solution
1- myCellList.css
.cellListWidget {
}
.cellListEvenItem {
display: inline-block;
cursor: pointer;
zoom: 1;
}
.cellListOddItem {
display: inline-block;
cursor: pointer;
zoom: 1;
}
.cellListKeyboardSelectedItem {
background: #ffc;
}
#sprite .cellListSelectedItem {
gwt-image: 'cellListSelectedBackground';
background-color: green;
color: white;
height: auto;
overflow: visible;
}
2- MyCellListResources.java
import com.google.gwt.user.cellview.client.CellList;
import com.google.gwt.user.cellview.client.CellList.Style;
public interface MyCellListResources extends CellList.Resources{
#Source({"myCellList.css"})
#Override
public Style cellListStyle();
}
3- YourMainPresenter.java
CellList<String> myHorizontalCellList = new CellList<String>(myTextCell, GWT.<MyCellListResources> create(MyCellListResources.class));
The code was tested & met your requirement.
It's not the .horizontalCellList that you want display: inline-block, it's the inner <div> elements for each item. The selector needs to be:
.horizontalCellList .gwt-CellList-cellListEvenItem, .horizontalCellList .gwt-CellList-cellListOddItem
assuming you #Imported CellList.Style on your CssResource.
(disclaimer: I only tried that in a completely re-defined custom CellList.Style, but there's no reason it wouldn't work with #Import and a descendant selector)

Resources