Skip to content

Instantly share code, notes, and snippets.

View Djuki's full-sized avatar

Ivan Đurđevac Djuki

  • Freelancer
  • Serbia
  • 02:00 (UTC -12:00)
  • X @Djuki
View GitHub Profile
@Djuki
Djuki / builder.html
Created February 10, 2023 14:24
Load SF builder with tollbar
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<link rel="stylesheet" href="http://localhost:44486/build/css/main.css">
<style>
#container {
display: flex;
flex-direction: column;
@Djuki
Djuki / stack.yml
Created August 13, 2021 06:47
WordPress local development environment with official docker image
version: '3.1'
services:
wordpress:
image: wordpress
restart: always
ports:
- 8080:80
environment:
@Djuki
Djuki / actions.js
Created March 28, 2020 10:35
Actiona
export const FETCH_MORE_BRANCHES = 'FETCH_MORE_BRANCHES';
export const SUCCESS_FETCH_BRANCHES = 'SUCCESS_FETCH_BRANCHES';
export function fetchMoreBranches(identityId, nextPage) {
return {
type: FETCH_MORE_BRANCHES,
identityId,
nextPage
};
}
<Select
options={branches}
onChange={this.onBranchChange}
value={this.state.selectedBranch}
onMenuScrollToBottom={() =>
this.props.fetchMoreBranches(this.props.identityId, this.props.branchesNextPage)
}
/>
@Djuki
Djuki / redux.js
Created March 13, 2020 11:23
Preloaded state
const preloadedState = {
repositories: {
identityId,
branches: [],
branchesNextPage: false,
}
};
let store = createStore(reducers, preloadedState, composeEnhancers(applyMiddleware(epicMiddleware)));
@Djuki
Djuki / container.js
Last active March 13, 2020 11:24
Mapping redux state and actions to the component
const mapStateToProps = state => ({ branchesNextPage: state.repositories.branchesNextPage });
const mapDispatchToProps = dispatch => ({
fetchMoreBranches: (id, nextPage) => dispatch(fetchMoreBranches(id, nextPage))
});
const AppContainer = connect(mapStateToProps, mapDispatchToProps)(App);
@Djuki
Djuki / reducer.js
Last active February 29, 2020 11:12
import React from 'react';
import { SUCCESS_FETCH_BRANCHES } from '../actions';
const repositories = (state = {}, action = []) => {
switch (action.type) {
case SUCCESS_FETCH_BRANCHES: {
return { ...state, branches: state.branches.concat(action.branches), branchesNextPage: action.nextPage };
}
default: {
import { FETCH_MORE_BRANCHES, successFetchBranches } from '../actions';
import { ofType } from 'redux-observable';
import { EMPTY, of } from 'rxjs';
import { ajax } from 'rxjs/ajax';
import { mergeMap, map, catchError } from 'rxjs/operators';
import tokenHeader from '../../common/helpers/token';
import { showAlertBox } from '../../common/layout';
const fetchLoadMoreBranchesEpic = action$ => {
return action$.pipe(
// Container component map dispactch action to the presentational component props
const mapDispatchToProps = dispatch => {
return {
fetchMoreBranches: (identityId, nextPage) => dispatch(fetchMoreBranches(identityId, nextPage))
};
};
const AppContainer = connect(mapStateToProps, mapDispatchToProps)(App);
<Select
options={branches}
onChange={this.onBranchChange}
value={this.state.selectedBranch}
onMenuScrollToBottom={() => {
if (this.props.branchesNextPage !== false) {
this.props.fetchMoreBranches(this.props.identityId, this.props.branchesNextPage);
}
}}
/>