1.0.0 • Published 7 years ago

non-destructive-map-merge v1.0.0

Weekly downloads
3
License
ISC
Repository
github
Last release
7 years ago

non-destructive-map-merge

A non-destructive-map-merge function for Sass

Credit: https://medium.com/@pentzzsolt/a-non-destructive-map-merge-function-for-sass-f91637f87b2e#.ekepo95qi

Example

$global-colors: (
	neutral: (
		x-light: #f1f1f1,
	),
	primary: #df2,
	secondary: (
		base: (
			old: red,
			new: green
		)
	),
	tertiary: (
		base: yellow
	)
);

$local-colors: (
	neutral: grey,
	primary: (
		light: #738bd3,
		base: #042f75
	),
	secondary: (
		light: #ffa75b
	),
	tertiary: (
		light: (
			first: orange,
			second: purple
		),
	),
	success: (
		base: #007b39
	)
);

$colors: non-destructive-map-merge($global-colors, $local-colors);

//Expected result:
//$colors: (
//	neutral: grey,
//		primary: (
//			light: #738bd3,
//			base: #042f75
//		),
//		secondary: (
//			base: (
//				old: red,
//				new: green
//			),
//		light: #ffa75b
//	),
//	tertiary: (
//		base: yellow,
//		light: (
//			first: orange,
//			second: purple
//		)
//	),
//	success: (
//		base: #007b39
//	)
//);