Skip to content

Instantly share code, notes, and snippets.

View lukaskleinschmidt's full-sized avatar

Lukas Kleinschmidt lukaskleinschmidt

  • Aachen, Germany
  • 14:10 (UTC +02:00)
View GitHub Profile
@mixin grid-fractions($divisors, $breakpoint: null) {
@each $divisor in $divisors {
@for $dividend from 1 through $divisor - 1 {
@if $breakpoint {
&--#{$dividend}\/#{$divisor}\@#{$breakpoint} {
flex-basis: $dividend / $divisor * 100%;
max-width: $dividend / $divisor * 100%;
}
}
@lukaskleinschmidt
lukaskleinschmidt / breakpoint.js
Last active June 28, 2017 14:16
javscript components
import Component from './component';
export default class Breakpoint extends Component {
init(mediaQueryString) {
const mql = window.matchMedia(mediaQueryString);
const listener = () => this.trigger(mql.matches ? 'match' : 'unmatch', [mql]);
mql.addListener(listener);
this.set('mql', mql);
import set from 'lodash/set';
import get from 'lodash/get';
import has from 'lodash/has';
export default class Component {
constructor() {
this._data = {};
this._observers = {};
this.init && this.init.apply(this, arguments);
}
@lukaskleinschmidt
lukaskleinschmidt / js-component.php
Last active October 9, 2017 07:16
Kirby JS Component
<?php
namespace LukasKleinschmidt\Component;
use HTML;
use STR;
use C;
/**
* Kirby Script Tag Component
@lukaskleinschmidt
lukaskleinschmidt / Readme.md
Last active May 9, 2019 11:59
Kirby 3 uuid

You would need to install https://github.com/ramsey/uuid to make it work. Depending on the use case it could also make sense to implement those as traits.

<?php

class ArticlePage extends UuidPage
{
  
}
@lukaskleinschmidt
lukaskleinschmidt / index.js
Last active October 2, 2020 14:06
Kirby Structure Field Preview
panel.plugin('lukaskleinschmidt/site', {
components: {
'k-structure-field-preview': {
props: {
value: String,
column: Object,
field: Object
},
computed: {
text: function() {
@lukaskleinschmidt
lukaskleinschmidt / index.php
Created October 23, 2020 08:35
Add page models automatically in Kirby 3
<?php
use Kirby\Cms\App as Kirby;
use Kirby\Cms\Page;
use Kirby\Toolkit\A;
class DefaultPage extends Page
{
//
}
@lukaskleinschmidt
lukaskleinschmidt / bootstrap.php
Created March 2, 2020 09:17
Kirby Thumbnails
<?php
// bootstrap/kirby.php
include dirname(__DIR__) . '/vendor/autoload.php';
$kirby = new Kirby([
'roots' => [
'base' => $base = dirname(__DIR__),
'index' => $base . '/public',
'content' => $base . '/content',
@lukaskleinschmidt
lukaskleinschmidt / barba.js
Last active May 23, 2023 08:54
Determine history direction in barba.js
import History from './history';
import Barba from 'barba.js';
const history = new History();
Barba.Pjax.goTo = function(url) {
history.goTo(url);
this.onStateChange();
};
@lukaskleinschmidt
lukaskleinschmidt / index.php
Last active June 15, 2023 08:36
Kirby Snippet Assets Plugin
<?php
use Kirby\Cms\App;
use Kirby\Toolkit\A;
App::plugin('lukaskleinschmidt/snippet-assets', [
'hooks' => [
'page.render:after' => function (string $contentType, string $html) {
if ($contentType === 'html') {
$html = preg_replace_callback('/<\/head>/', fn ($matches) =>