auto commit 11/03/2019 Sun

master
Mashiro 5 years ago
parent 2d70da49e9
commit db84b915c0
  1. 136
      index.html
  2. 103
      src/scss/layouts/postThumbList.scss
  3. 13
      src/scss/variables.scss
  4. 126
      src/ts/components/auto-init.ts
  5. 8
      src/ts/components/mdcConf.ts
  6. 8
      src/ts/components/mdcInit.ts

@ -5,6 +5,7 @@
<title>Sakura v2</title>
<link rel="stylesheet" href="./dist/bundle.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://at.alicdn.com/t/font_679578_dgipmwt51qb.css">
</head>
<body>
@ -34,7 +35,7 @@
<!--index cover image-->
<figure data="mark" id="cover-img-container">
<div data="layer" id="img-view" data-depth="0.5">
<img data="cover" id="cover-img" src="https://api.2heng.xin/cover/">
<img data="cover" id="cover-img" src="https://view.moezx.cc/images/2019/10/21/1zuypi4mkggq6js5lqxt3sjaa.jpg">
</div>
</figure>
<div class="cover-video-container"></div>
@ -47,91 +48,80 @@
<section class="main-center">
<div class="post-list">
<!--post thumb list-->
<div class="mdc-card demo-card demo-basic-with-text-over-media">
<div class="mdc-card__primary-action demo-card__primary-action" tabindex="0">
<div class="mdc-card__media mdc-card__media--16-9 demo-card__media"
style="background-image: url(&quot;https://material-components.github.io/material-components-web-catalog/static/media/photos/3x2/2.jpg&quot;);">
<div class="mdc-card__media-content demo-card__media-content">
<div class="demo-card__primary">
<h2 class="demo-card__title mdc-typography mdc-typography--headline6">Our Changing Planet</h2>
<h3 class="demo-card__subtitle mdc-typography mdc-typography--subtitle2">by Kurt Wagner</h3>
<!--thumb right template-->
<div class="mdc-card post-thumb-item">
<div class="mdc-card__primary-action mdc-ripple-upgraded primary-action">
<div class="content">
<div class="post-info">
<div class="text">
<h4 class="mdc-typography mdc-typography--subtitle1 post-date">
<i class="iconfont icon-time"></i> Posted on 2018-05-25 <i class="iconfont hotpost icon-hot"></i>
</h4>
<h3 class="mdc-typography mdc-typography--headline5 post-title">
Our Changing Planet
</h3>
<h4 class="mdc-typography mdc-typography--subtitle1 post-meta">
<i class="iconfont icon-attention"></i> 8 332 Hits
<i class="iconfont icon-mark"></i> 26 Comments
<i class="iconfont icon-file"></i> Child
</h4>
<div class="mdc-typography mdc-typography--body2 post-abstract">
Visit ten places on our planet that are undergoing the biggest changes today.
</div>
</div>
<div class="btn--align-left">
<button class="mdc-button mdc-button--outlined">Read</button>
</div>
</div>
<div class="post-thumb">
<div href="#" class="thumb-img-box">
<img src="https://view.moezx.cc/images/2019/10/21/5e65o9lxtbvht2tdjvpgsmarw.jpg">
</div>
</div>
</div>
<div class="demo-card__secondary mdc-typography mdc-typography--body2">Visit ten places on our planet that
are undergoing the biggest changes today.</div>
</div>
<div class="mdc-card__actions">
<div class="mdc-card__action-buttons">
<button class="mdc-button mdc-card__action mdc-card__action--button">Read</button>
<button class="mdc-button mdc-card__action mdc-card__action--button">Bookmark</button>
</div>
<div class="mdc-card__action-icons">
<button class="mdc-icon-button mdc-card__action mdc-card__action--icon--unbounded" aria-pressed="false"
aria-label="Add to favorites" title="Add to favorites">
<i class="material-icons mdc-icon-button__icon mdc-icon-button__icon--on">favorite</i>
<i class="material-icons mdc-icon-button__icon">favorite_border</i>
</button>
<button class="mdc-icon-button material-icons mdc-card__action mdc-card__action--icon--unbounded"
title="Share" data-mdc-ripple-is-unbounded="true">share</button>
<button class="mdc-icon-button material-icons mdc-card__action mdc-card__action--icon--unbounded"
title="More options" data-mdc-ripple-is-unbounded="true">more_vert</button>
</div>
</div>
</div>
<!--thumb right template end-->
<div class="mdc-card demo-card demo-basic-with-text-over-media">
<div class="mdc-card__primary-action demo-card__primary-action" tabindex="0">
<div class="mdc-card__media mdc-card__media--16-9 demo-card__media"
style="background-image: url(&quot;https://material-components.github.io/material-components-web-catalog/static/media/photos/3x2/2.jpg&quot;);">
<div class="mdc-card__media-content demo-card__media-content">
<div class="demo-card__primary">
<h2 class="demo-card__title mdc-typography mdc-typography--headline6">Our Changing Planet</h2>
<h3 class="demo-card__subtitle mdc-typography mdc-typography--subtitle2">by Kurt Wagner</h3>
<!--thumb left template-->
<div class="mdc-card post-thumb-item">
<div class="mdc-card__primary-action mdc-ripple-upgraded primary-action">
<div class="content">
<div class="post-thumb">
<div href="#" class="thumb-img-box">
<img src="https://view.moezx.cc/images/2019/10/21/1owb0inchnbrhkamrpk10a2ff.jpg">
</div>
</div>
</div>
<div class="demo-card__secondary mdc-typography mdc-typography--body2">Visit ten places on our planet that
are undergoing the biggest changes today.</div>
</div>
<div class="mdc-card__actions">
<div class="mdc-card__action-buttons">
<button class="mdc-button mdc-card__action mdc-card__action--button">Read</button>
<button class="mdc-button mdc-card__action mdc-card__action--button">Bookmark</button>
</div>
<div class="mdc-card__action-icons">
<button class="mdc-icon-button mdc-card__action mdc-card__action--icon--unbounded" aria-pressed="false"
aria-label="Add to favorites" title="Add to favorites">
<i class="material-icons mdc-icon-button__icon mdc-icon-button__icon--on">favorite</i>
<i class="material-icons mdc-icon-button__icon">favorite_border</i>
</button>
<button class="mdc-icon-button material-icons mdc-card__action mdc-card__action--icon--unbounded"
title="Share" data-mdc-ripple-is-unbounded="true">share</button>
<button class="mdc-icon-button material-icons mdc-card__action mdc-card__action--icon--unbounded"
title="More options" data-mdc-ripple-is-unbounded="true">more_vert</button>
</div>
</div>
</div>
<div class="post-info">
<div class="text">
<h4 class="mdc-typography mdc-typography--subtitle1 post-date">
<i class="iconfont icon-time"></i> Posted on 2018-05-25 <i class="iconfont hotpost icon-hot"></i>
</h4>
<h3 class="mdc-typography mdc-typography--headline5 post-title">
Our Changing Planet
</h3>
<h4 class="mdc-typography mdc-typography--subtitle1 post-meta">
<i class="iconfont icon-attention"></i> 8 332 Hits
<i class="iconfont icon-mark"></i> 26 Comments
<i class="iconfont icon-file"></i> Child
</h4>
<div class="mdc-typography mdc-typography--body2 post-abstract">
Visit ten places on our planet that are undergoing the biggest changes today.
</div>
</div>
<div class="user-info mdc-text-field mdc-text-field--outlined">
<input type="text" id="tf-outlined" class="mdc-text-field__input">
<div class="mdc-notched-outline">
<div class="mdc-notched-outline__leading"></div>
<div class="mdc-notched-outline__notch">
<label for="tf-outlined" class="mdc-floating-label">Your Name</label>
<div class="btn--align-right">
<button class="mdc-button mdc-button--outlined">Read</button>
</div>
</div>
</div>
<div class="mdc-notched-outline__trailing"></div>
</div>
</div>
<!--thumb left template end-->
<button class="commit-button mdc-button mdc-button--outlined">
<span class="mdc-button__label">BuiBuiBui~</span>
</button>
<button class="mdc-button mdc-button--unelevated">Learn More</button>
</div>
<!--post-list end-->
<!--post-list end-->
</section>
<aside class="side-bar-right">right</aside>
</div>

@ -2,27 +2,84 @@
@import "@material/button/mdc-button";
@import "@material/typography/mdc-typography";
.demo-card {
width: 350px;
margin: 48px 0;
}
.demo-basic-with-text-over-media .demo-card__media-content {
display: -ms-flexbox;
display: flex;
-ms-flex-align: end;
align-items: flex-end;
}
.demo-card__primary {
padding: 1rem;
}
.demo-basic-with-text-over-media .demo-card__media-content .demo-card__subtitle,
.demo-basic-with-text-over-media .demo-card__media-content .demo-card__title {
color: #fff;
}
.demo-basic-with-text-over-media .demo-card__secondary {
padding-top: 1rem;
.post-thumb-item {
height: 300px;
margin: 10px;
.primary-action {
height: 100%;
.content {
height: 100%;
width: 100%;
display: -webkit-flex;
display: flex;
flex-flow: row nowrap;
justify-content: space-between;
.post-info {
width: 45%;
height: 100%;
display: -webkit-flex;
display: flex;
flex-flow: column nowrap;
justify-content: space-between;
.text {
margin: 30px;
.post-title {
margin: 0;
color: $font-color-normal;
}
.post-date,
.post-meta {
margin: 0;
color: $font-color-light;
font-size: 12px;
i {
font-size: 12px;
}
}
.post-abstract {
margin: 20px 0;
color: $font-color-light;
}
}
.btn--align-left {
margin: auto auto 30px 30px;
}
.btn--align-right {
margin: auto 30px 30px auto;
}
}
.post-thumb {
width: 55%;
overflow: hidden;
.thumb-img-box {
height: 100%;
width: 100%;
img {
width: 100%;
height: 100%;
object-fit: cover;
transition: all .6s;
&:hover {
transform: scale(1.1);
}
}
}
}
}
}
}

@ -2,7 +2,12 @@
* MDC varibles
* must before import
*/
$mdc-theme-primary: #fcb8ab;
$mdc-theme-secondary: #feeae6;
$mdc-theme-on-primary: #442b2d;
$mdc-theme-on-secondary: #442b2d;
$mdc-theme-primary: #fcb8ab;
$mdc-theme-secondary: #feeae6;
$mdc-theme-on-primary: #442b2d;
$mdc-theme-on-secondary: #442b2d;
/* font color */
$font-color-light:#888;
$font-color-normal: #504e4e;
$font-color-dark:#000;

@ -1,126 +0,0 @@
/**
* @license
* Copyright 2016 Google Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
// tslint:disable:only-arrow-functions
import {MDCComponent} from '@material/base/component';
import {MDCFoundation} from '@material/base/foundation';
import {strings} from './constants';
const {AUTO_INIT_ATTR, AUTO_INIT_STATE_ATTR, INITIALIZED_STATE} = strings;
export interface MDCAttachable {
new<F extends MDCFoundation>(root: Element, foundation?: F, ...args: Array<unknown>): MDCComponent<F>;
// Static method.
attachTo<F extends MDCFoundation>(root: Element): MDCComponent<F>;
}
interface InternalComponentRegistry {
[key: string]: MDCAttachable;
}
const registry: InternalComponentRegistry = {};
const CONSOLE_WARN = console.warn.bind(console); // tslint:disable-line:no-console
function emit<T extends object>(evtType: string, evtData: T, shouldBubble = false) {
let evt;
if (typeof CustomEvent === 'function') {
evt = new CustomEvent<T>(evtType, {
bubbles: shouldBubble,
detail: evtData,
});
} else {
evt = document.createEvent('CustomEvent');
evt.initCustomEvent(evtType, shouldBubble, false, evtData);
}
document.dispatchEvent(evt);
}
/* istanbul ignore next: optional argument is not a branch statement */
/**
* Auto-initializes all MDC components on a page.
*/
export function mdcAutoInit(root = document) {
const components = [];
//捕获所有节点
let nodes: Element[] = [].slice.call(root.querySelectorAll(`[${AUTO_INIT_ATTR}]`));
nodes = nodes.filter((node) => node.getAttribute(AUTO_INIT_STATE_ATTR) !== INITIALIZED_STATE);
for (const node of nodes) {
const ctorName = node.getAttribute(AUTO_INIT_ATTR);
if (!ctorName) {
throw new Error('(mdc-auto-init) Constructor name must be given.');
}
const Constructor = registry[ctorName]; // tslint:disable-line:variable-name
if (typeof Constructor !== 'function') {
throw new Error(
`(mdc-auto-init) Could not find constructor in registry for ${ctorName}`);
}
// TODO: Should we make an eslint rule for an attachTo() static method?
// See https://github.com/Microsoft/TypeScript/issues/14600 for discussion of static interface support in TS
//const buttonRipple = new MDCRipple(document.querySelector('.mdc-button'))
const component = Constructor.attachTo(node);
Object.defineProperty(node, ctorName, {
configurable: true,
enumerable: false,
value: component,
writable: false,
});
components.push(component);
node.setAttribute(AUTO_INIT_STATE_ATTR, INITIALIZED_STATE);
}
emit('MDCAutoInit:End', {});
return components;
}
// Constructor is PascalCased because it is a direct reference to a class, rather than an instance of a class.
// tslint:disable-next-line:variable-name
mdcAutoInit.register = function(componentName: string, Constructor: MDCAttachable, warn = CONSOLE_WARN) {
if (typeof Constructor !== 'function') {
throw new Error(`(mdc-auto-init) Invalid Constructor value: ${Constructor}. Expected function.`);
}
const registryValue = registry[componentName];
if (registryValue) {
warn(`(mdc-auto-init) Overriding registration for ${componentName} with ${Constructor}. Was: ${registryValue}`);
}
registry[componentName] = Constructor;
};
mdcAutoInit.deregister = function(componentName: string) {
delete registry[componentName];
};
mdcAutoInit.deregisterAll = function() {
const keys = Object.keys(registry) as string[];
keys.forEach(this.deregister, this);
};
// tslint:disable-next-line:no-default-export Needed for backward compatibility with MDC Web v0.44.0 and earlier.
export default mdcAutoInit;

@ -5,9 +5,9 @@
* @license MIT
*/
import { MDCRipple } from '@material/ripple'
import { MDCTextField } from '@material/textfield'
import { MDCTopAppBar } from '@material/top-app-bar'
import { MDCRipple } from '@material/ripple';
import { MDCTextField } from '@material/textfield';
import { MDCTopAppBar } from '@material/top-app-bar';
const Conf = [
['.mdc-top-app-bar', MDCTopAppBar],
@ -15,7 +15,7 @@ const Conf = [
[
[
'.mdc-button',
'.demo-card__primary-action',
'.primary-action',
],
MDCRipple
],

@ -7,12 +7,16 @@
import mdcConf from "./mdcConf"
const Conf = mdcConf
/**
* Initial [material-components-web](https://github.com/material-components/material-components-web/)
* through configuration in `mdcConf.ts``.
* See <https://git.io/JegHJ>
*/
export default function () {
/* See https://git.io/JegHJ */
let components = []
for (const i of Conf) {
if (typeof (i[0]) == 'string') {
console.log(i)
const component = i[0]
const constructor = i[1]
components.map.call(document.querySelectorAll(component), function (e: any) {

Loading…
Cancel
Save